Shared Libraries on a classroom PC(Windows)?

So in a classroom with potentially hundreds of users/students how/where can I place libraries so that all users will be able to see/use them? I don't want each user to have to added them which will waste time and their limited file space.

In 1.8.10 I just put them in C:\Program Files (x86)\Arduino\libraries and it works fine, but how do I do this in 2.1.1 ?

Hi @dtstrgt. The libraries subfolder of the Arduino IDE 1.x installation is what is referred to as the "built-in" libraries folder. Arduino IDE 2.x also uses a "built-in" libraries folder, but it is in a different location. By default, the location is here:

C:\Users\<username>\AppData\Local\Arduino15\libraries

(where <username> is the Windows username)

But this location is configurable. It is configured via the directories.builtin.libraries configuration key in the file at this path:

C:\Users\<username>\.arduinoIDE/arduino-cli.yaml

So, for example, if you wanted to configure Arduino IDE 2.x to use libraries from a shared folder at path C:\arduino-builtin-libraries, you would change this part of the file:

directories:
  data: C:\Users\<username>\AppData\Local\Arduino15
  downloads: C:\Users\<username>\AppData\Local\Arduino15\staging
  user: C:\Users\<username>\Documents\Arduino

to this:

directories:
  builtin:
    libraries: C:\arduino-builtin-libraries
  data: C:\Users\<username>\AppData\Local\Arduino15
  downloads: C:\Users\<username>\AppData\Local\Arduino15\staging
  user: C:\Users\<username>\Documents\Arduino

For this sort of system administration application, you might prefer an automated/programmatic approach to working with this configuration file. Arduino provides a command line tool named "Arduino CLI":

https://arduino.github.io/arduino-cli/latest/

Arduino CLI has a dedicated functionality for working with this configuration file:

https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_config_set/

So you can do this:

arduino-cli config set --config-file "$Env:HOMEDRIVE$Env:HOMEPATH\.arduinoIDE\arduino-cli.yaml" directories.builtin.libraries "C:\arduino-builtin-libraries"

(I used PowerShell, but you can adapt this to whatever shell you are working with)

The arduino-cli.yaml file uses the standard YAML language, so you can also use any other tool that supports working with YAML. I can recommend the excellent yq for this purpose:

Thanks I will need to look at this when/if I get time.

So if I reconfigure the location of the libraries will users still be able to add to their personal space as is the case with 1.8.10 ? My initial reaction is it was much easier in 1.8.x and while I'd like to use the new 2.x we may stick with the old for another year.

Are you asking whether they can install arbitrary libraries without that action affecting the environment of the other users on the machine? If so, the answer is "yes". When the user installs libraries , they do it to the libraries subfolder of the path configured via the "Sketchbook location" preference. This is a separate location from the "built-in" libraries folder.

Under the hood, the "Sketchbook location" preference is stored in the directories.user key of the arduino-cli.yaml file.

Something you might find beneficial about the new "built-in" libraries system is that the storage of the libraries outside the Arduino IDE installation means that your own additions to the "built-in" libraries folder are not affected by updating the IDE, as was the case with Arduino IDE 1.x.

Err but each user will have their own arduino-cli.yaml which doesn't even exist until they've used Arduino on that particular PC at which point then they have to edit it and repeat this on each PC they login to?

Where do the default contents of arduino-cli.yaml come from?

Sorry I'm really not understanding how this is better than 1.8.x .

Maybe we just give up trying to help the students and if 1000 students want to use the same libraries on the classroom PCs then each of them will have to install them, which is what they will have to do if they use it on a personal PC.

The system administrator would set it up for each user account in advance.

The Arduino CLI codebase:

The file is generated via a arduino-cli config init command:

https://arduino.github.io/arduino-cli/latest/commands/arduino-cli_config_init/

Feel free to continue using Arduino IDE 1.8.x if you think it's better.

I'd like to use/explore the "new" versions, plus even if we advice the students to use the latest legacy version some won't and it can confuse them using two different version.

Thanks for trying to explain, still 50/50 on which way to go.

Or we could just drop Arduino and use a different platform :upside_down_face:

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.