Skip to content

Added an option to use a local arduino-cli.yaml to add, for example, custom library paths. Which is a common request. #59

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

goodchip
Copy link

Many people on the web can't find a solution to make the Arduino-CLI look for their custom libraries in a specific location for each of their projects.

I propose an option to have the extension look for a local arduino-cli.yaml file at the root of the project in order to be able to define these paths (and also further customize the behavior of the Arduino-CLI according to each project).

Capture d’écran 2025-01-10 à 14 47 54 Capture d’écran 2025-01-10 à 14 51 21 Capture d’écran 2025-01-10 à 14 52 42

For reference, here is the list of possibilities offered by this configuration file: https://arduino.github.io/arduino-cli/latest/configuration/


Background:

Since the loss of compatibility with the Arduino IDE with version 2 and the mandatory use of the Arduino-CLI, many people have the problem that they do not know how to include their custom libraries anymore:
microsoft#1653 (comment)

It used to be possible to place an arduino-cli.yaml file at the root of the project:
microsoft#1614 (comment)
https://arduino.github.io/arduino-cli/0.22/configuration/#locations

Unfortunately, for security reasons, the latest versions of the Arduino-CLI no longer support the use of a local file.
arduino/arduino-cli#758
https://arduino.github.io/arduino-cli/1.1/configuration/#locations
Since February 2023, only the use of environment variables and the --config-file option are supported.

The only viable solution is to add an arduino-cli.yaml file in the "Arduino15" directory on your operating system. However, there remains a problem: the paths declared in this way are global, a certain number of users are looking for a way to be able to choose the libraries to use depending on their project.
#50 (comment)

Since VSCode does not support environment variables in this context, the only solution is to modify the Arduino extension for VSCode to use the --config-file parameter of the Arduino-CLI.

So I added an option for the extension to fetch a local arduino-cli.yaml at the root of the project using the config-file parameter, thus solving the problem.

Copy link

@lersi lersi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good

@lersi
Copy link

lersi commented Jan 21, 2025

Hello, thank you very much for the contribution, sorry for the delay.
Waiting for CI to pass

@lersi
Copy link

lersi commented Jan 21, 2025

The problem with MacOS is related to outdated CI, merging your contribution

@lersi lersi merged commit 00cc5f1 into vscode-arduino:main Jan 21, 2025
2 of 3 checks passed
@goodchip
Copy link
Author

Hello Lersi,

thanks for the merge :)

However I forgot to modify the README.md, it will probably be necessary to document the new functionality.

I wish you a happy new year 2025!

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

Successfully merging this pull request may close these issues.

2 participants