PlatformIO IDE messes up PATH with incorrect default folders (Windows 10)

Environment: Windows 10 + VS Code with PlatformIO addon.

PlatformIO IDE messes up the PATH environment variable which causes that I am unable to run the pio command in the PlatformIO IDE in terminal window.

Over time my .platformio folder has grown to more than 6 GB in size eating up valuable space on my Windows system drive. To free up space I recently moved the .PlatformIO folder from C:\Users\<user>\.platformio to D:\Users\<user>\.platformio.

I read that I had to set environment variable PLATFORMIO_CORE_DIR and let it point to the new folder to make PlatformIO aware of the new location. I also read that I had to update file .vscode\c_cpp_properties.json in each of my projects and replace the old path with the new (to prevent any error messages). I did both.

I also updated my (user) PATH environment variable which contained C:\Users\<user>\.platformio\penv\Scripts;C:\Users\<user>\.platformio\penv. I changed the drive letters in both folder paths from C: to D:

For a while everything appeared to work fine, until I wanted to use the pio command in VSCode terminal window again (for the first time in the new situation). I got the following error:

pio: The term ‘pio’ is not recognized as a name of a cmdlet, function, script file, or executable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.

Outside of VSCode/PlatformIO IDE I can run the pio command just fine because the penv and Scripts folders are included in PATH but within the IDE in a terminal window it does not work.

After doing some tests I noticed that the PlatformIO IDE messes up the PATH environment variable. It removes the correct


from my PATH and inserts


somewhere at the beginning of the PATH instead which causes the problem. These folders do not even exist because everything is on drive D:.

I checked the PlatformIO settings in VSCode but could not find find any occurrence of C:\Users\<user>\.platformio that I could update.


  • Why stealthly modify the PATH environment variable and why remove already present correct values?!

  • Why force apparently (incorrect) hard coded values instead of using the correct folder paths? Is this a bug in PlatformIO?

    There is no need to make changes to the PATH environment variable without consent and the correct paths can be easily determined from the value of PLATFORMIO_CORE_DIR.

  • How to fix this?

Have you restarted your computer after creating the PLATFORMIO_CORE_DIR variable? When you restart VSCode after, does the PlatformIO extension load, and are you able to access a CLI and run pio system info to verify the installation path?

I’ve successfully done changing the PlatformIO core path with that technique, see Specify Path to PlatformIO in Visual Studio Code - #11 by maxgerhardt.

Many times since but to no effect.


No, not inside VSCode (unless ‘clean start’, see below).
Yes, outside VSCode.
Both as previously described.

> pio system info
--------------------------  -------------------------------------------------------
PlatformIO Core             5.2.0a6
Python                      3.9.2-final.0
System Type                 windows_amd64
Platform                    Windows-10
File System Encoding        utf-8
Locale Encoding             cp1252
PlatformIO Core Directory   D:\Users\<user>\.platformio
PlatformIO Core Executable  D:\Users\<user>\.platformio\penv\Scripts\platformio.exe
Python Executable           d:\users\<user>\.platformio\penv\scripts\python.exe
Global Libraries            0
Development Platforms       9
Tools & Toolchains          50
--------------------------  -------------------------------------------------------

So system info looks all right.

I did some further investigation and made several discoveries:

  • After opening VSCode, closing all folders (VSCode always opens my latest latest files/PlatformIO project), closing VSCode and then starting VSCode again (to get a freshly started VSCode without any open folder/file/project) the PATH is exactly the same in a (PowerShell) terminal window within VSCode as it is outside VSCode (with correct paths and correct drive letter for my .platformio folder and I am now able to normally run the pio command inside the terminal window.
    (I call this situation clean start).

  • In the ‘clean start’ situation the PlatformIO addon loads and the Platform Icon appears in the left-side pane and the PlatformIO toolbar appears at the bottom.
    However: If I try to open PlatformIO Home (e.g. via Home button in the toolbar) then PlatformIO Home fails to open and after very long time the following error is displayed:

    Error: Could not start PIO Home server: Error: timeout at

    What is going on here?
    (Looks like VSCode addon settings for the PlatformIO addon may require some update).

  • When I open an existing PlatformIO project (folder) in VSCode then the problem which I initially described pops up again: the PATH is modified with incorrect (old) .platformio folder paths for the C: drive where it was previously installed. So something is stored with the project settings which messes this all up.

  • I found the cause in file <some-PlatformIO-project>\.vscode\settings.json:

      "": {
          "PATH": "C:\\Users\\<user>\\.platformio\\penv\\Scripts;C:\\Users\\<user>\\.platformio\\penv;C:\\WINDOWS\\system32;C:\\WINDOWS;C:\\Program Files (x86)\\Tools;C:\\WINDOWS\\System32\\Wbem;C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\;C:\\Python27\\;C:\\Python27\\Scripts;
          "PLATFORMIO_CALLER": "vscode"

    What the crap?!
    This appears to be a path from very long time ago and it is frozen in time, ‘hard-coded’ hidden in a settings file in the .vscode folder and this is used every time the project is opened! Whatever changes have been made to my PATH environment variable since this setting was stored (frozen) by the PlatformIO IDE or VSCode, those changes will never be used! (e.g. Folder C:\\Python27 may have existed once but not for long time`.)

    I’m not sure why this setting was automatically stored there but it appears related to the PlatformIO addon, causes problems (and looks like a code smell).

Hopefully @ivankravets can shine some light on this.

Above data was anonymized. The actual user name has been replaced with <user>.

I’ve never seen this file being generated by PlatformIO. It is also not in the template files for VSCode.

I would just suggest a removal of the PlatformIO VSCode extension, removal of any custom VSCode settings.json settings regarding the path, and a reinstallation of the PIO VSCode plugin. It should pick up the environment variable properly and use the core in D:\.

A stored PATH like described above is present in 110 of my PlatformIO projects! I will now have to clean this up and remove it from 110 project folders/settings files. :astonished: :frowning_face: :unamused:

These are older projects so it may be related to an older PlatformIO version but those incorrect settings are still active and used.

Maybe @ivankravets knows more.

Removing and reinstalling the PatformIO extension fixed the issue that I was unable to open PlatformIO Home in the ‘clean start’ situation described above.

1 Like