Hi @Andy-A. I can suggest a couple of alternatives:
Dedicated Sketchbook
A simple way to achieve a reasonably good level of isolation of library dependencies is to use a dedicated sketchbook for each project. In addition to being a convenient location for storing your sketches, Arduino IDE installs libraries to the libraries
subfolder of the sketchbook. So the sketchbook is a significant part of the sketch's "environment".
You can easily change the location of the sketchbook folder by doing the following:
- Select File > Preferences from the Arduino IDE menu.
- Set the Sketchbook location preference to the folder where you would like to store the project's dedicated sketchbook.
- Click the "OK" button.
With this approach, your projects will still share the same boards platform installations, including their "platform bundled" library.
Sketch Build Profiles
If you don't mind using a command line interface, you might be interested in the "build profiles" feature of the official Arduino CLI tool:
https://arduino.github.io/arduino-cli/latest/sketch-project-file/#build-profiles
This allows you to define the versions of each of the platform (AKA "core") and library dependencies of a sketch in a metadata file and ensure those versions will be used when compiling and uploading it.
The dependencies of each project is stored in a dedicated, isolated folder so you can use different versions of a given dependency in each of your projects.
This doesn't reach quite the level of build reproducibility as using a separate portable installation of Arduino IDE 1.x for each project as described by @sterretje since the version of Arduino CLI in use is still a variable in the build results. However, if you are concerned about that, it would be reasonable to simply document which version of Arduino CLI the sketch was verified with. An alternative would be to just bundle Arduino CLI with the sketch (similar to the "portable IDE" approach some have suggested here). Unlike Arduino IDE, Arduino CLI is a lightweight single executable file, so bundling it with the sketch is less impactful. But if, as stated, the goal is only to control library dependencies, the build profiles feature will be plenty sufficient.