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
D:\Users\<user>\.platformio\penv\Scripts;D:\Users\<user>\.platformio\penv
from my PATH and inserts
C:\Users\<user>\.platformio\penv\Scripts;C:\Users\<user>\.platformio\penv
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.
Questions
-
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?