arduino-cli
arduino-cli copied to clipboard
--library flag not working with relative paths
Bug Report
Sometimes you want to download a library which is not available through the Library Manager or is in development (not released/tagged).
The workflow would be to keep this version of the library in a different place than the Sketchbook's libraries folder, especially if you already have another version of this library installed either manually or through the Library Manager.
When doing this, via arduino-cli you can specify --library and pass in a full path to the library.
One use case would be to cd into one of the examples and run a compile/upload targeting the path 2 folders up (../../).
This will result in an error or in the Library installed in the Sketchbook to be used if present.
Current behavior
I will be using ArduinoIoTCloud to explain what happens.
Install the library with arduino-cli lib install ArduinoIoTCloud. This will give us all the dependencies required.
Uninstall the library, this will remove only ArduinoIoTCloud and not the installed dependencies:
arduino-cli uninstall ArduinoIoTCloud
- download the library from its repo (https://github.com/arduino-libraries/ArduinoIoTCloud) to a folder of your choosing (for me it'll be
~/Downloads) - expand the archive
cdinto its examples folder and ArduinoIoTCloud-Basic$> cd ~/Downloads/ArduinoIoTCloud/examples/ArduinoIoTCloud-Basic- try to compile the example with
arduino-cli compile -b arduino:samd:nano_33_iot --library ../../ -vThe path is valid, but compilation will end with the following errorError during build: stat ../../../src/ArduinoIoTCloud.cpp: no such file or directory
If on the other hand I pass in the full path it will compile without issues
arduino-cli compile -b arduino:samd:nano_33_iot --library ~/Downloads/ArduinoIoTCloud-master
If the library is re-installed arduino-cli lib install ArduinoIoTCloud, when passing ../../ as path to the Library there will be no error, but the library will be picked from the Sketchbook's libraries folder
$~ArduinoIoTCloud-Basic> arduino-cli compile -b arduino:samd:nano_33_iot --library ../../ -v
...
...
Multiple libraries were found for "ArduinoIoTCloud.h"
Used: /Users/ubidefeo/data/Dropbox/AppsDocuments/Arduino/libraries/ArduinoIoTCloud
Not used: /Users/ubidefeo/data/GITHub/Arduino-Libs/ArduinoIoTCloud
Expected behavior
When passing in a valid path to a Library, it should always be chosen above all other instances of it
Environment
- CLI version (output of
arduino-cli version): 0.21.0 - OS and platform: Mac OS 12.2.1 Monterey