Skip to content
This repository was archived by the owner on Oct 1, 2024. It is now read-only.

Can't find library when switched to CLI #1595

Open
av4625 opened this issue Feb 17, 2023 · 10 comments
Open

Can't find library when switched to CLI #1595

av4625 opened this issue Feb 17, 2023 · 10 comments

Comments

@av4625
Copy link

av4625 commented Feb 17, 2023

I got a message in VS Code to say that the legacy IDE was going to be removed and to move to the bundled CLI. So I did. Now when I click the little verify button to build my project it can't find one of the libraries. The library is in my sketchbook libraries directory.

It worked before switching to CLI and when I open the Arduino IDE 1.8.19 and click verify it works fine.

fatal error: ezButton.h: No such file or directory

% pwd
/Users/<user>/Documents/Development/Arduino/libraries
% ls ezButton 
README.md		keywords.txt		src
examples		library.properties
% ls ezButton/src 
ezButton.cpp	ezButton.h

I use a Mac.
Extension version v0.5.0

@github-actions github-actions bot added the triage New issues that have not been reviewed. label Feb 17, 2023
@robotdad
Copy link
Member

I do not believe the CLI shares the directories with the legacy IDE. Can you try restoring the libraries using the menus in VS Code?

@MatthewSteeves
Copy link

MatthewSteeves commented Feb 18, 2023

I had same problem after accepting same prompt to swtich to CLI, and can confirm that @robotdad's suggestion worked for me! Thanks @robotdad!

VS code Output window showed a bit of encouraging but confusing output (note: I had extension's verbose logging turned on)

[Starting] Install library - Servo
Downloading [email protected]...
[email protected] [email protected] already downloaded
Installing [email protected]...
Installed [email protected]
[Done] Installed library - Servo

Manually running the arduino-cli lib list before and after:

PS C:\Users\Matt\.vscode\extensions\vsciot-vscode.vscode-arduino-0.5.0-win32-x64\assets\platform\win32-x64\arduino-cli> .\arduino-cli.exe lib list
No libraries installed.
PS C:\Users\Matt\.vscode\extensions\vsciot-vscode.vscode-arduino-0.5.0-win32-x64\assets\platform\win32-x64\arduino-cli> .\arduino-cli.exe lib list
Name  Installed     Available         Location              Description
Servo 1.1.8         -                 LIBRARY_LOCATION_USER -

I'll admit I find library management within the VS code extension a bit mysterious. For instance, now that I switched to the CLI, I'm not sure where the extension searches for libraries and where additional libraries paths can be configured. Should I do it with the arduino-cli.exe directly?

I've just seen that within the Arduino library manager in VScode, there's an "Installed" Type filter, and for each of the library's the filter shows, there's an with an option to "include library". That's great! While I was aware of the the Library Manager and Type filter, I hadn't considered that "Installed" would be a Type and so I didn't even bother to explore the drop-down menu closer. 🤦‍♂️
EDIT: "Include Library" didn't do what I thought it would do (ie "make it discoverable by the VS code/arduino-cli"), it just seems to add the "include" directive for you. Which is ok now that I know.

Now to just understand where the library path's are specified and config'd...

@av4625
Copy link
Author

av4625 commented Feb 18, 2023

I didn’t know you could install libraries through VS code, I’ll have a look to see how to do this.

Does anyone know where the libraries get stored when doing it this way? Specifically on Mac?

I had to fix/modify a couple of libraries to build for ESP32 as its compiler is more strict on warnings. For these I forked the library, added a fix commit and then installed the library manually by cloning my forked repo.

@av4625
Copy link
Author

av4625 commented Feb 18, 2023

[Starting] Remove library - ezButton
[Done] Removed library - ezButton

[Starting] Install library - ezButton
Downloading [email protected]...
[email protected] [email protected] already downloaded
Installing [email protected]...
Installed [email protected]
[Done] Installed library - ezButton

Library manager in vscode showed it was already installed, I had to remove then reinstall. It uses the original library location, I had changed mine to a slighty different location. Can I do this with the extension?

image

The examples are still from my modified library location.

@av4625
Copy link
Author

av4625 commented Feb 18, 2023

I think this setting needs to be ported to the extension as I don't want to be forced to use Documents/Arduino/libraries it seems that the examples in the comment above is already using this setting to find the libraries.
setting

Edit:
https://arduino.github.io/arduino-cli/0.30/configuration/
directories->user is what is required I think

@av4625
Copy link
Author

av4625 commented Feb 18, 2023

Would be nice if --export-binaries could be used as well

@rtnate
Copy link

rtnate commented Mar 1, 2023

I fixed this by setting an environment variable ARDUINO_DIRECTORIES_USER to match my sketchbook directory on an extra hard drive (in my case on windows, E:\source\arduino). You will have to restart vscode for it to pull it in. I did it quickly through System Properties.

@cechurat
Copy link

Following works for me on Windows:
PowerShell: cd .\.vscode\extensions\vsciot-vscode.vscode-arduino-0.6.0-win32-x64\assets\platform\win32-x64\arduino-cli\
.\arduino-cli.exe config init
.\arduino-cli.exe config set directories.user "<YOUR_SKETCHBOOK_LOCATION>"

If you want to check it type:
.\arduino-cli.exe config dump and you should see the path you entered before.

Toggle the VS Code and try to Verify your project. In file .vscode\c_cpp_properties.json check the property "includePath" which should reflect your changes.

@vmajor
Copy link

vmajor commented Dec 19, 2023

I do not believe the CLI shares the directories with the legacy IDE. Can you try restoring the libraries using the menus in VS Code?

What do you mean? I too am horribly stuck trying to migrate to VSC from Arduino IDE. VSC with the bundled arduino-cli cannot find my libraries and I have no idea how to help it.

@gcstr
Copy link

gcstr commented Aug 17, 2024

I have the same problem here. The libraries are installed, but the VSCode plugin won't recognize it.

Screenshot 2024-08-17 at 18 39 39

My CLI reports that the libraries are installed just as VSCode:

➜ arduino-cli lib list
Name            Installed Available     Location Description
FTDebouncer     1.3.3     -             user     -
lvgl            8.3.10    9.1.0         user     Full-featured Graphics Library for Em...
TFT_eSPI        2.5.34    2.5.43        user     TFT graphics library for Arduino proc...
TFT_eSPI_Setups           -             user     -

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants