Skip to content

lib list --fqbn does not shown platform bundled lib when lib of same name installed globally #1566

Closed
@per1234

Description

@per1234

Describe the problem

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 does not list the platform bundled library when the library of the same name is installed globally (e.g. in directories.user).

To reproduce

$ 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
Name    Installed       Available     Location            Description
USBHost 1.0             1.0.5         arduino:[email protected] Allows the communication with USB per...

🙂 Output is as expected

$ arduino-cli lib install USBHost
$ arduino-cli lib list USBHost
Name    Installed     Available         Location              Description
USBHost 1.0.5         -                 LIBRARY_LOCATION_USER -

🙂 Output is as expected

$ arduino-cli lib list --all USBHost
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...

🙂 Output is as expected

$ arduino-cli lib list --all --fqbn arduino:samd:mkrzero USBHost
No libraries installed.

🐛 The library is not listed even it is installed.

Because the LIBRARY_LOCATION_USER 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.

Expected behavior

arduino-cli lib list --all --fqbn should always list all installed libraries matching the search query.

Arduino CLI version

nightly-20211112 Commit: bf4a784

Operating system

Windows

Operating system version

10

Additional context

The compilation process correctly discovers the platform bundled library even though it was not shown in the lib-list --fqnb output:

$ 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
[...]

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.

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

Metadata

Metadata

Assignees

Labels

criticality: mediumOf moderate impactpriority: lowResolution is a low prioritytopic: codeRelated to content of the project itselftype: imperfectionPerceived defect in any part of project

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions