Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Libraries are not re-scanned prior to install operation when in gRPC daemon mode #1802

Closed
3 tasks done
per1234 opened this issue Jul 12, 2022 · 0 comments · Fixed by #2037
Closed
3 tasks done

Libraries are not re-scanned prior to install operation when in gRPC daemon mode #1802

per1234 opened this issue Jul 12, 2022 · 0 comments · Fixed by #2037
Assignees
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface type: imperfection Perceived defect in any part of project

Comments

@per1234
Copy link
Contributor

per1234 commented Jul 12, 2022

Describe the problem

The Arduino CLI daemon scans the installed libraries when a gRPC client instance is initialized. Library installation operations are based on the data from the scan.

The data from this scan will not be accurate if any of the following has occurred after a scan:

The first two are not uncommon for the user to do.

🐛 The result of library installation operations may be incorrect due to the libraries on disk not matching the internal data.

To reproduce

Set up

$ arduino-cli version
arduino-cli.exe  Version: 0.25.0-rc1 Commit: 63b53c0f Date: 2022-07-12T01:46:05Z

$ export ARDUINO_DIRECTORIES_USER="/tmp/arduino-cli-directories-user" # Use a clean directories.data for demo

$ arduino-cli daemon

Demo

Use grpcurl to run the following commands in another terminal:

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Create

{
  "instance": {
    "id": 1
  }
}

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Init

$ export ARDUINO_DIRECTORIES_USER="/tmp/arduino-cli-directories-user"

$ arduino-cli lib install SD@1.2.3  # Change the libraries after Arduino CLI gRPC initialization

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}, "name": "SD", "version": "1.2.4"}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.LibraryInstall

ERROR:
  Code: Unknown
  Message: destination dir C:\Users\per\AppData\Local\Temp\arduino-cli-directories-user\libraries\SD already exists, cannot install

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.Init

$ grpcurl \
  -plaintext \
  -import-path ./rpc \
  -proto cc/arduino/cli/commands/v1/commands.proto \
  -d '{"instance": {"id": 1}, "name": "SD", "version": "1.2.4"}' \
  127.0.0.1:50051 \
  cc.arduino.cli.commands.v1.ArduinoCoreService.LibraryInstall

{
  "taskProgress": {
    "name": "Downloading SD@1.2.4"
  }
}
{
  "progress": {
    "file": "SD@1.2.4",
    "completed": true
  }
}
{
  "taskProgress": {
    "completed": true
  }
}
{
  "taskProgress": {
    "name": "Installing SD@1.2.4"
  }
}
{
  "taskProgress": {
    "message": "Replacing SD@1.2.3 with SD@1.2.4"
  }
}
{
  "taskProgress": {
    "message": "Installed SD@1.2.4",
    "completed": true
  }
}
{

}

🐛 The library installation failed incorrectly due to the Arduino CLI gRPC daemon not being aware of the change that occurred externally. It was necessary to reinitialize the instance in order to make it behave correctly.

Expected behavior

Libraries are re-scanned at the start of every library installation operation.

Arduino CLI version

0.25.0-rc1 Commit: 63b53c0

Operating system

Windows

Operating system version

10

Additional context

This is a similar problem to #1755. However, it was not introduced by the commit reported there.

Issue checklist

  • I searched for previous reports in the issue tracker
  • I verified the problem still occurs when using the nightly build
  • My report contains all necessary details
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project topic: gRPC Related to the gRPC interface labels Jul 12, 2022
@ubidefeo ubidefeo added this to the 0.29.0 milestone Oct 27, 2022
@umbynos umbynos assigned Bikappa and unassigned cmaglie Jan 18, 2023
@per1234 per1234 added the conclusion: resolved Issue was resolved label Jan 24, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
conclusion: resolved Issue was resolved topic: code Related to content of the project itself topic: gRPC Related to the gRPC interface type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants