Description
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:
- Manual changes to library installations
- Installations made via the
cc.arduino.cli.commands.v1.ArduinoCoreService.ZipLibraryInstall
method - Installations made via the
cc.arduino.cli.commands.v1.ArduinoCoreService.GitLibraryInstall
method
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