PIO Debug doesn't work when specifying default_envs in ini file

In a project using an LPC1769 mcu I’ve added a debug environment in platformio.ini like so: [env:LPC1769Debug]
extends = env:LPC1769
build_type = debug
build_flags = …
debug_tool = …
debug_server = …

But when I set default_envs = LPC1769Debug as below:
[platformio]
src_dir = …
boards_dir = …
default_envs = LPC1769Debug
include_dir = …

and then click the green arrow next to PIO Debug (upper left corner)…it gives an error message stating " cannot find task…"

Inspecting launch.json the task is there
“version”: “0.2.0”,
“configurations”: [
{
“type”: “platformio-debug”,
“request”: “launch”,
“name”: “PIO Debug”,
“executable”: “c:/Users/tony/Documents/CNC/MAINBOARD/Marlin-bugfix-2.0.x 020221/.pio/build/LPC1769Debug/debug/firmware.elf”,
“projectEnvName”: “LPC1769Debug”,
“toolchainBinDir”: “C:/Users/tony/.platformio/packages/toolchain-gccarmnoneeabi/bin”,
“svdPath”: “C:/Users/tony/.platformio/platforms/nxplpc-arduino-lpc176x/misc/svd/LPC176x5x_v0.2.svd”,
“preLaunchTask”: {
“type”: “PlatformIO”,
“task”: “Pre-Debug (LPC1769Debug)”
},
“internalConsoleOptions”: “openOnSessionStart”
},

BUT, it has the default_envs value appended to it “task”: “Pre-Debug (LPC1769Debug)”

Just guessing, I removed the (LPC1769Debug) so the task becomes “task”: “Pre-Debug”, and then everything is fine. The PIO Debug arrow works as expected. It stays that way until a “Clean” command is run, then it re-writes the launch.json file to contain “task”: “Pre-Debug (LPC1769Debug)” again, and of course the PIO Debug arrow is broken once again.

Is this a bug or am I doing something incorrectly?

1 Like

This is indeed a bug. This is also noted in Debugger does not honor selected environment · Issue #4098 · platformio/platformio-core · GitHub.

As there is already an issue opened for it, it will be discussed there.

1 Like

Yes, a known defect.

Whenever I get that message on PIO debug launch, I’ve got into the habit of going straight into the launch.json and removing the text appended to “task”. Hopefully a fix will come in the next PlatformIO release.

Thanks guys. I wanted to make sure it wasn’t something I caused.
I can deal with removing the extra text as workaround till the issue is fixed.

If you install the “Platform dev” version of PlatformIO and ensure you are using the latest PlatformIO IDE extension, this error will not occur and you will not have to go into launch.json to fix the issue.

  1. I moved to “platformIO dev” branch and I also checked that I had the latest “PlafformIO IDE” extension installed. To move to platformIO dev branch, Go too File menu -> Preferences -> settings. Search for platformio-ide.useDevelopmentPIOCore and set it on with a check mark.
  2. go to extensions view on left-hand panel: ensure you have PlatformIO IDE 2.2.1 installed

Wait for PlatformIO to change over to .dev and reload when it tell you too.
Your problem should now be fixed.

Thanks for the tips!