'Sealed' Environments for different projects

Hi all,
I'm reading here a lot about problems with multiple libraries of the same type.
Here I have the problem of having also the same library with different versions,
depending on the project I'm working on.

A simple but effective solution would be to have a 'sealed' environment, wherein
the compiler runs, with own libraries that are the only ones seen to the project.

then you can easily delete unwanted ones without affecting other projects,
or even have different versions of the libraries and - to be the best - can archive a
whole set to freeze it for versioning.

The working set could be identified by a name and e.g. called via command line parameter.
The storage space should be relative to the sketch, so everything could be easily copied
or moved.

For backward compatibility, there could be a basic work set, that uses the currently used directory paths.

Regards
Wolpi

You can achieve this by changing the sketchbook location:

arduino --pref sketchbook.path=~/sketchbook1 --save-prefs
arduino ~/sketchbook1/SketchThatNeedsSketchbook1Libraries

or on Windows:

arduino_debug --pref sketchbook.path=c:\sketchbook1 --save-prefs
arduino c:\sketchbook1\SketchThatNeedsSketchbook1Libraries

This will result in the libraries bundled with the Arduino IDE and the hardware package for the currently selected board being shared, while the libraries installed to each sketchbook folder are isolated from each other.

Another option is to bundle the specific libraries with the sketch:

SketchThatNeedsSpecificLibraryVersion
|_SketchThatNeedsSpecificLibraryVersion.ino
|_src
|_SpecificLibrary
|_library.properties
|_src
|_SpecificLibrary.h
|_SpecificLibrary.cpp

Then the #include directive for the library looks like this:

#include "src/SpecificLibrary/SpecificLibrary.h"

You also might be interested in this:

Well, that's a possible way, but has some drawbacks:

  • the 'standard' libraries are still active / searched
  • you have to copy the necessary libraries manually to the sketch location
  • you can not use the library manager to select / update the libraries

to use all benefits, you should be able to specify the library (search) path.

wolpi:

  • you have to copy the necessary libraries manually to the sketch location
  • you can not use the library manager to select / update the libraries

I gave two possible solutions:

  • separate sketchbooks
  • bundle libraries with the sketch

Those two issues you raised only apply to the second solution.