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
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!
@mogplus8 Your contribution is always welcome!
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”.
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!
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
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.
It’s new since extension version 2.3.0 – also see IDE compiles wrong Project File - #6 by maxgerhardt