Build project using pre-configured platformio.ini

I’m new to Platformio and it’s quite hard to set it up to my whishes.

I’m using PIO with VSCode for Arduino and want to set up a standard path where I have my libaries on my computer.

Found out I have to put the path in the .ini file but I don’t want to do it everytime I creat a new project. So my research bring me to this site (Redirecting...) where it says “build project using pre-configured platformio.ini” but I don’t understand how it will work.
It seems I have to type “pio ci -c, --project-conf C:/***/platformio.ini” in the terminal right?
But does it remember this configuration for the next time I create a new project or do I have to do it again?
Is there another solution to set a standard path where PIO will search?

Per project possible using lib_extra_dirs = <path to your arduino library folder>, but not globally. Open an feature request issue at Issues · platformio/platformio-core · GitHub.

This is for continuous integration (CI) and not really what you want here. Via -c you can give the path to the config aka platformio.ini to the build process.


I can’t help but think that you want to stick to old Arduino IDE habits and try to solve the wrong problem.

In the Arduino IDE, libraries need to go into a global directory that is shared by all Arduino sketches. The down-side is that a sketch is not self-contained: if you share it with a friend, you need to provide additional instructions about the libraries that need to be downloaded and installed. And if your friend has another library installed with a header file that has the same name as a header file in the required libraries, it might not even compile…

The PlatformIO apprach is different: The required libraries are declared in platformio.ini in each project. You don’t need to download and install libraries – PlatformIO takes care of it. You can easily share a PlatformIO project and it will compile without further instructions.

So are you familiar with this concept? Are you using lib_deps in platformio.ini?

This post mainly applies to published libraries. If you are using private libraries that are shared across several projects, then you should look into lib_extra_dirs as proposed by maxgerhardt.

1 Like

You’re right. I want to keep my arduino libaries where they are and only refer to the folder. I know the benefits and it’s good for sharing but if I’m alone I can save some space (even nowadays it’s not critical).
It would be great if there is a workaround to use an own .ini file or an option in the settings to type the libraries directory path.

1 Like

In that case, I see two main options at present (in order of preference):

  1. lib_extra_dirs as suggested by maxgerhardt (link to documentation is in that post). This will let you point PlatformIO to a global library storage directory on a project by project basis. It does mean you will need to add that parameter to each project you create, but to my mind that’s not much of a hassle, as it’s a quick copy and paste from the nearest project at hand.
  2. Installing libraries globally. When you do this, libraries will be automatically installed to the $HOMEDIR/.platformio/libs folder, and only one copy of the library will be retained (unless multiple versions are needed? unsure on this point) for all your projects. This seems like a good idea at first, until you work with multiple platforms. You’ll then encounter issues when a globally installed library that is compatible with say the AtmelAVR boards, but not the Espressif8266 boards, will seemingly randomly cause your project to fail to build. Hence why I prefer option 2.

Having said that, I don’t bother with either, and just use project level library management. However, I can appreciate the desire to minimise disk usage. Reality is the libraries are pretty small, it’s all the temporary build files and intellisense database storage that take up all the space… (i.e. intellisense gobbles up 100mb per project in it’s indexing of all the functions, variables, etc… or at least used to… haven’t checked it for a few months).

1 Like

Okay thanks everybody.

For now I go with the lib_extra_dirs-solution.

Not happy but it will do the job. :confused: