Vscode-arduino: Add option to configure additional library folders by using arduino.json or settings.json

Created on 5 Jun 2019  路  7Comments  路  Source: microsoft/vscode-arduino

arduino-builder supports the "-libraries" parameter to add additional library folders (multiple!).

Both arduino.json and settings.json (in the workspace/.vscode/* folder) do not support setting the "-libraries" parameter, thus making it impossible to put code that is used in multiple sketches at other locations than the default library location ("C:Program Files (x86)Arduinolibraries") and the user library location ("C:UsersUSERDocumentsArduinolibraries").

This is very inconvenient for development environments that do not allow the use of these local directories. For example: environments which demand all code (sketches and shared code) to be under source control.

Please add a setting for adding additional library folders (enable the use of the -libraries parameter) in arduino.json or settings.json.

The same holds for being able to customize the 'sketchbook location' in arduino.json or settings.json for which "C:UsersUSERDocumentsArduino" is the default.

stale

Most helpful comment

Revive this issue.
Excellent editor is worthless if we have to change to another editor to include libraries.

I agree fully. Also The effort to implement should be small, because arduino-builder supports this by using the -libraries parameter. So the issue is purely: make it configurable in arduino.json or settings.json and then use the configured values with the -libraries parameter when calling the build executable (arduino-builder). The trick of using values from arduino.json or settings.json as parameter for the build process is already done for other configurable options.... so implementing it for the libraries should be really easy.

All 7 comments

Not having the option to add additional library folders makes the vscode-arduino extension impractical (an not usable) in a more professional sw development environment.

You should be able to include code/libs from other workspaces or directories than your current workspace (a bit like how Visual Studio uses projects and solutions).

A partial work around (currently) is to change the sketchbook.path entry in the Arduino preferences.txt file. $HOME/.arduino15/preferences.txt on my Fedora 30 system.
A single entry, but at least you can move the sketchbook, and contained libraries path, to some place else. Per user, per folder, configuration overrides, and a list, would be nice.

This issue has been automatically marked as stale and closed because it has not had recent activity. Please feel free to open a new issue if you would like further discussion. Thank you for your contributions.

Revive this issue.
Excellent editor is worthless if we have to change to another editor to include libraries.

Revive this issue.
Excellent editor is worthless if we have to change to another editor to include libraries.

I agree fully. Also The effort to implement should be small, because arduino-builder supports this by using the -libraries parameter. So the issue is purely: make it configurable in arduino.json or settings.json and then use the configured values with the -libraries parameter when calling the build executable (arduino-builder). The trick of using values from arduino.json or settings.json as parameter for the build process is already done for other configurable options.... so implementing it for the libraries should be really easy.

I found a way around this, but I think its weird someone has made the efford to configure include paths settings, and then limited those to not work with users library paths ?"?陇%"?

The solution (for Windows 10 in my case) is to have a private library somewhere, lets say as a sibling to your project folders, maybe all at the same level, and then make a junction link in the workspace path, to the real library folder. You should then gitignore the junction folder, and add the real folder to Git instead. You can include classes from sub folders by #include "Library/Classes/someclass.h", provided the junction is named "Library". I use this setup for many projects with VS code and the MS Arduino extension, having many private classes in the Library folder. Its not perfect, but it works and is practical as the "Library" junction and its sub folders and classes are all visible from the project workspace.

I have a project which includes a ./libraries folder with a number of included libraries which works fine with the Arduino IDE 1.8.13 when I set my Sketchbook location to the project folder.

I can't seem to figure out any way to do this using the Arduino extension in vscode.

$ tree -d libraries
libraries
|-- Adafruit_BusIO
|   `-- examples
|       |-- i2c_address_detect
|       |-- i2c_readwrite
|       |-- i2c_registers
|       |-- i2corspi_register
|       |-- spi_modetest
|       |-- spi_readwrite
|       |-- spi_register_bits
|       `-- spi_registers
|-- Adafruit_MCP4725
|   `-- examples
|       |-- sinewave
|       `-- trianglewave
|-- Adafruit_MCP9600_Library
|   |-- assets
|   `-- examples
|       `-- mcp9600_test
|-- Adafruit_RGB_LCD_Shield_Library
|   |-- examples
|   |   `-- HelloWorld
|   `-- utility
|-- SerialMenu
|   |-- examples
|   |   |-- demo1
|   |   `-- demo2
|   `-- src
`-- arduino-sht
    `-- examples
        |-- multiple-sht-sensors
        |-- sht-autodetect
        `-- sht3xanalog

vscode:

Version: 1.53.0
Commit: 8490d3dde47c57ba65ec40dd192d014fd2113496
Date: 2021-02-03T16:01:04.046Z (1 day ago)
Electron: 11.2.1
Chrome: 87.0.4280.141
Node.js: 12.18.3
V8: 8.7.220.31-electron.0
OS: Darwin x64 19.6.0

vsciot-vscode.vscode-arduino: v0.3.4

Was this page helpful?
0 / 5 - 0 ratings

Related issues

momiccioli picture momiccioli  路  4Comments

khaled-hamam picture khaled-hamam  路  4Comments

boskoe picture boskoe  路  3Comments

vishnumaiea picture vishnumaiea  路  6Comments

liydu picture liydu  路  4Comments