PlatformIO builds "wrong" project

Good morning.
I use PlatformIO Core 4.3.3 / Home 3.2.1 with VSCodium 1.44.1 on a Windows10 PC.
Each time when I open a new project (Quick Access on the Home Screen) and try to build the project the project which was loaded before is builded.
First I have to open the platformio.ini file of the desired project to force the correct build.
Is this correct ?
Thanks and regards
Rainer

Hi @Rainer1 and welcome to the community! Youā€™ll find a lot of help here.

Iā€™m no guru but I had a similar problem, and Iā€™m still not completely across it, but I think what happens is this.

Platformio/VS Code can have multiple projects open at the same time. If you see a workspace name or ā€œUntitled (workspace)ā€ in the explorer bar chances are you have two (or more) projects open. If so you can right click on the project(s) you do not want and select ā€œremove folder from workspaceā€, so that only the project you are working on is loaded into PlatformIO. When you build then, this should be the project that gets compiled and uploaded.

VS code also lets you keep files from a project open even if the project is not in the explorer bar any more. So if you remover a folder from the workspace one or more files from the project could still be open for editng. I make it a rule to close all the files for a project files before I remove the project folder, then there is hopefully less chance of editing the wrong file and wondering why your changes arenā€™t doing anything (been there, done thatā€¦).

Finally, itā€™s my understanding, but I could be wrong, that PlatformIO will build everything that is loaded in the explorer bar. Not necessarily the files you have open for editing. So if you have multiple projects loaded it will build them all. This may not be what you want to happen. Itā€™s probably good for larger projects with a lot of functionality, that can be broken down into sub-projects managed in different folders, but for small projects, Iā€™ve found anyway, keeping all the files in one folder (i.e. project) works fine, and I have everything in one project.

Hope this helps.

BTW this is a first for me too. Iā€™ve asked a lot of questions in this forum and received a LOT of help, but this is the first time Iā€™ve had a shot at answering a question. So I hope my answer helps. If Iā€™m wrong the gurus will sort it out!

:wink:

1 Like

@mogplus8 Your contribution is always welcome! :slight_smile:

My only point of clarification would be:

I donā€™t think this is the caseā€¦ you might be confusing this with a single project that has multiple boardsā€¦ only one project will be built at a time, but if there are multiple boards, if you do the ā€¦ global? ā€¦ build option, all boards of that project will be built. If youā€™re only interested in the one board, better to either pick build against that specific board (ā€˜environmentā€™) or specify it as the default board for that project (`default_envsā€™).

In a nutshell, whatever project the file/tab you have in focus belongs to will be the one that is built.

Thanks guys for the feedback. What you describe is identically to what I observe.
(Only one project was ever build)
Iā€™m missing a menu item ā€œselect activ projectā€ or "close project " (see Eclipse or other IDEā€™s)
The current behaviour is a bit strange from my point of view.
I will check the VSCode / VSCodium pages if I found any helpfull information concerning his ā€œissueā€.

1 Like

Equivalent of that would be the default_envs platformio.ini parameter. You wonā€™t find any PlatformIO configuration stuff in the menus - as all that is VSCode related. Youā€™ll only find stuff in PIO Home.

Edit: A feature slated to be added to the PlatformIO VSCode extension 2.0 which is currently in development is the ability to select the project without needing to edit the platformio.ini, so keep an eye out for that!

1 Like

Now I removed an opened project always from workspace before using a different one and it worked as expected. This flow is ok for me.

Thanks and regards
Rainer

Iā€™m confused by this. I donā€™t see where the environment sets the project directory. I get this error semi-regularly, and itā€™s quite annoying.

Are you selecting the right project and environment per the new selector? IDE compiles wrong Project File - #4 by maxgerhardt

Oh, wow. There it is right there in the toolbar. Donā€™t know how new that is or how I missed it, but thatā€™s exactly what Iā€™m looking for.

Thanks.

Itā€™s new since extension version 2.3.0 ā€“ also see IDE compiles wrong Project File - #6 by maxgerhardt