PlatformIO Community

Moving (Complex?) portable arduino setup to PlatformIO

I have been using arduino for a large number of projects for many years, and would like to move this over to Platformio however i’m not sure how to do that properly.

–Background –
My current setup which works very well is as follows:

Arduino is installed in portable mode, in a folder on onedrive, which means there are 2 library folders:

%onedrive%\arduino\libraries (base libraries - and some install here on portable for some reason)
%onedrive%\arduino\portable\sketchbook\libraries (portable libraries)

The actual arduino sketches are stored in:

The packages and boards are in:

Through the Arduino IDE everything works perfectly… I have ~70 libraries and ~160 sketches, and all load from the UI and work just fine. They get synchronized everywhere by OneDrive and it all works fine, no matter where onedrive is located on the many machines I work on as the environment variable always allows me to find the correct onedrive.

I also have a Portable Install of VS Code with PlatformIO in that OneDrive… and again that works absolutely fine. (I check the code from most stuff there into git)

–The problem–

What I would like to do is to combine the 2 and be able to use VS Code/PlatformIO to edit and build the Arduino sketches, without moving them out of the folder or messing with them too much (so that they still work in the Arduino IDE also for now)

I read about the libdeps_dir setting in platformio.ini, however I believe I would need to go and add that to each of the ~160 sketches manually after creating a platformio.ini by opening them one at a time, to get that method working, adding both
%onedrive%\arduino\libraries and %onedrive%\arduino\portable\sketchbook\libraries
to it.

Is there some way to make that change globally so that I dont have to add to each platformio.ini and it becomes a default setting? (And is that global configuration portable - i.e. not a system set environment var etc, as those dont work on a new system, without having to set them again.)

Has anyone attempted to do this and had any success? Or am I going about this in a completely nonsensical way?

Thanks in advance for a)reading this far, b) any pointers you may be able to offer…

I found this question while attempting to move a vendor’s project from Arduino to PlatformIO. I figured out the solution myself so I leave it here in case it can help someone else: in platformio.ini, I added the following line to the [env] section:

lib_extra_dirs = ../LTSketchbook/libraries

In your case, I guess you could just add:

lib_extra_dirs = onedrive/arduino/libraries onedrive/arduino/portable/sketchbook/libraries

Then PlatformIO will find your sketches.