VSCode+PIO+x86 Windows: Error executing

Hello all,
I try to use VSCode+PIO in order to develop Windows console programs. Therefore, I installed the x86 Windows Desktop platform, from PIO. The hello-world program compiles, links etc. sucessfully, and I can execute the program.exe from the console. However, executing from VS Code fails with a message box:

The preLaunchTask 'undefined' terminated with exit code 1

In the VS code console the following message appears:

> Executing task: C:\Users\eble\.platformio\penv\Scripts\platformio.exe debug <

Error: Please setup environments in `platformio.ini` file
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

This is my platformio.ini (2 lines), I didn’t modify it:

[env:windows_x86]
platform = windows_x86

I noticed that there is something wrong in the description at platform-windows_x86/examples/hello-world at master · platformio/platform-windows_x86 · GitHub

on how to run the program:

# Run program
> .pioenvs/native/program

The .pioenvs directory doesn’t exist. Instead, the path to the executable should be: .pio/build/windows_x86/program.exe as is written correctly in my launch.json. I am not sure if this is related to my error.

Any help would be appreciated.

Best regards

Johannes

.pioenvs was the old folder name for .pio\ a PlatformIO version ago, the docs seem outdated.

What do you press in VSCode do make this error appear?

1 Like

Hello maxgerhardt,

thanks for you quick response.

In VSCode I hit the Run Button from the lefthand Activity Bar, then then RUN Symbol under the Edit menu. I can also choose Run->Start Debugging or Run->Run without Debugging. It doesn’t matter, I always get this error.

Best regards

Johannes

I’ve done a PR to update those instructions with the correct path, so thanks for pointing that out! :slight_smile:

I suspect the Error: Please setup environments in platformio.ini file is a product of no debug related entries in the platformio.ini. I don’t think PlatformIO supports running a compiled executable locally, and it seems when you choose either Run -> Start Debugging or Run -> Start without Debugging that platformio debug is called in either case, hence the error.

AFAIK, the recommended way to run a compiled program is basically run it from the terminal, but hopefully someone will point out an easier way! :wink:

Hi pfeerick,

thanks for your reply. Sorry, it’s a little bit off-topic, but this is my background:
We are giving an embedded programming course at university for EE students. We will use a Pololu robot board, therefore we use VSCode/PIO. In the beginning, I would like to repeat C/C++ (without the embedded headachs). They are used (if they remember) to code in C/C++ with Qt Creator, so I thought it would be best to repeat C/C++ with VSCode so they (and I for that, I know VS Code for jscript and PHP only) can learn VSCode while refreshing C/C++ (native, on Windows) with at least hassle as possible (the C++ beast alone is hard enough IMHO). That means for me: The students don’t have to fiddle with VS Code json files, and they don’t have to launch the console manually, just like they are used with QT Creator. But using Qt Creator only for the repetition and than switching to VSCode is not the best option for me. I also have tried the VSCode “Easy C++ Projects” and “C/C++ Project Generator” extensions without much success in this respect, either.