Visual Studio Code, PlatformIO en CoPilot

When you have access to copilot for VSCode either free or the paid version, out of the box paths are not correct for the copilot agent to run platformIO builds. The path to pio.exe is available when running the command ‘PlatformIO: New Terminal’ as it will set it’s environment correctly.

But when Github Copilot will try to compile your project using the pio command, it will open a new standard powershell terminal window, and the environment for standard powershell is not changed, thus you (and copilot) will get an error pio.exe is not found.

Solution:
Lookup your environment varianble setting (bij typing $PROFILE in the powershell terminal windows in VSCode). Probably this will be:


C:\Users\<your current user account>\Documents\PowerShell\Microsoft.PowerShell_profile.ps1

And this file will not exist. Create that file and put following content inside:

$env:PATH += ";C:\Users\<your user account>\.platformio\penv\Scripts"

Close your powershell terminal windows, and restart them. Type pio.exe and you should get output.