arduino-cli
arduino-cli copied to clipboard
`lib list --fqbn` does not shown platform lib when lib of same name installed globally
It is a common practice for boards platforms to contain platform bundled libraries that are a variant of a common library distributed via Library Manager, modified to be compatible with the architecture of the boards platform (example).
arduino-cli lib list currently does not list these platform bundled libraries when the library of the same name is installed globally (e.g. in directories.user). This behavior is a bug.
Demonstrations
$ arduino-cli version
arduino-cli.exe alpha Version: nightly-20211112 Commit: bf4a784 Date: 2021-11-12T01:26:50Z
$ arduino-cli lib uninstall USBHost # Clean up in case you already had the lib installed
$ arduino-cli core install arduino:samd
$ arduino-cli lib list --all --fqbn arduino:samd:mkrzero USBHost # Output is as expected
Name Installed Available Location Description
USBHost 1.0 1.0.5 arduino:[email protected] Allows the communication with USB per...
$ arduino-cli lib install USBHost
$ arduino-cli lib list USBHost # Output is as expected
Name Installed Available Location Description
USBHost 1.0.5 - LIBRARY_LOCATION_USER -
$ arduino-cli lib list --all USBHost # Output is as expected
Name Installed Available Location Description
USBHost 1.0.5 - LIBRARY_LOCATION_USER -
USBHost 1.0 1.0.5 arduino:[email protected] Allows the communication with USB per...
$ arduino-cli lib list --all --fqbn arduino:samd:mkrzero USBHost # Output not as expected!
No libraries installed.
$ mkdir /tmp/SomeUSBHostSketch
$ printf "#include <KeyboardController.h>\nvoid setup() {}\nvoid loop() {}\n" > /tmp/SomeUSBHostSketch/SomeUSBHostSketch.ino # sketch that uses an arbitrary header from the USBHost libs
$ arduino-cli compile -b arduino:samd:mkrzero -v /tmp/SomeUSBHostSketch
[...]
Multiple libraries were found for "KeyboardController.h"
Used: C:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\libraries\USBHost
Not used: C:\Users\per\Documents\Arduino\libraries\USBHost
Using library USBHost at version 1.0 in folder: C:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\samd\1.8.11\libraries\USBHost
[...]
Because the globally installed version of "USBHost" is specified for sam architecture, it is reasonable that it not be shown in arduino-cli lib list --fqbn arduino:samd:mkrzero output (because that board is samd architecture), but the version of the library bundled with the arduino:samd platform should be shown.
As shown by the sketch compilation at the end of the demonstration above, the compilation process continues to correctly recognize the platform bundled library.
Even though it results in the example above exhibiting the most dramatic form of the bug's manifestation, the bug is not dependent on an architecture mismatch of the Library Manager lib, as the demonstration below shows.
In the following demonstration, the globally installed library is shown in the lib list output because it is compatible with the board's mbed_portenta architecture, but the platform bundled library is incorrectly not shown in the output, just as in the previous demonstration.
$ arduino-cli lib uninstall WiFi # Clean up in case you already had the lib installed
$ arduino-cli core install arduino:mbed_portenta
$ arduino-cli lib list --all --fqbn arduino:mbed_portenta:envie_m7 WiFi # Output is as expected
Name Installed Available Location Description
WiFi 1.0 1.2.7 arduino:[email protected] WiFi wrapper for mbed wifi classes
$ arduino-cli lib install WiFi
$ arduino-cli lib list WiFi # Output is as expected
Name Installed Available Location Description
WiFi 1.2.7 - LIBRARY_LOCATION_USER -
$ arduino-cli lib list --all WiFi # Output is as expected
Name Installed Available Location Description
WiFi 1.2.7 - LIBRARY_LOCATION_USER -
" 1.0 1.2.7 arduino:[email protected] WiFi wrapper for mbed wifi classes
$ arduino-cli lib list --all --fqbn arduino:mbed_portenta:envie_m7 WiFi # Output not as expected!
Name Installed Available Location Description
WiFi 1.2.7 - LIBRARY_LOCATION_USER -
$ mkdir /tmp/SomeWiFiSketch
$ printf "#include <WiFi.h>\nvoid setup() {}\nvoid loop() {}\n" > /tmp/SomeWiFiSketch/SomeWiFiSketch.ino # sketch that uses an arbitrary header from the WiFi libs
$ arduino-cli compile -b arduino:mbed_portenta:envie_m7 -v /tmp/SomeWiFiSketch
[...]
Multiple libraries were found for "WiFi.h"
Used: C:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\2.5.2\libraries\WiFi
Not used: C:\Users\per\Documents\Arduino\libraries\WiFi
Using library WiFi at version 1.0 in folder: C:\Users\per\AppData\Local\Arduino15\packages\arduino\hardware\mbed_portenta\2.5.2\libraries\WiFi
[...]
arduino-cli lib list --all --fqbn could be a very useful tool for investigating library dependency resolution outcomes, which are regularly a source of confusion for platform and library developers and users when a different library from the one they expected is selected. But, with this bug, it would end up only contributing more confusion since the library that will be selected by the build system is not even shown in the lib list output.
Expected behavior
arduino-cli lib list --all --fqbn should always list all installed libraries matching the search query.
Environment
- OS: Windows 10
- Version: nightly-20211112 Commit: bf4a784 Date: 2021-11-12T01:26:50Z