-
-
Notifications
You must be signed in to change notification settings - Fork 799
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Platformio overwrites .vscode/launch.json, breaking official VSCode documentation, preventing project-specific settings #3824
Comments
A work-around for this is to add platform-specific launch tasks to the global (per user) configuration as described here. Use case for me is adding to VSCode with platformio the vue.js debugging and dev tooling as described here - and this is a per-project setup. |
Why do you need Vue.JS debugger for the embedded project? |
Hi Ivan, and thanks for the reply. I built an AJAX web application front-end and back-end running on an embedded web server on the ESP32. You could do this without an application framework, and in fact the current version, which is not ready for production, does not even have the vue.js application running, but has some custom JavaScript for this. But the modular architecture of the framework is supposed to help when more features are added, and also you have pre-built components for visualisation of streaming measurement data from the microcontroller etc. |
Hi Ivan, Best regards, Pekka |
Hi, this is an inconvenience on my end as well. I'd love to be able to change this. Could you point out where/how in the code the launch.json rewrite action happens? @ul-gh mentioned the template being within the /penv folder, but I'm also seeing a launch.json template in the package.json of Thanks, |
Sorry for the issue. We will fix it in 5.1.1 soon. |
Hi Guys, I'm on: My launch.json is getting overwritten. As far as I can see here this shouldn't be happening? |
If you have broken JSON, it will be overwritten. https://jsonformatter.curiousconcept.com/ |
Thanks, not sure what broken JSON is. Whitespace should have no impact? |
Please share the raw JSON here. |
That is what is removed, Perfectly valid JSON. Putting it through the pretty printer does stop it being removed though:
|
Also the only reason I am doing it like this is I can't work out how to get a normal |
Yes, you need https://docs.platformio.org/en/latest/projectconf/sections/env/options/debug/debug_extra_cmds.html debug_extra_cmds =
set serial baud 115200 Does it work? If does not, please try |
Hi @ivankravets Thanks very much for the info, unfortunately neither of these worked with I had tried I just tried
Thanks very much for the help with this it is much appreciated. Cheers Andy |
I think this should be reopened.
One could use relative paths and distribute it with the git repository. E.g. of relative paths: {
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug",
"executable": "${workspaceFolder}/semihosting/.pio/build/nucleo_l452re/firmware.elf",
"projectEnvName": "nucleo_l452re",
"toolchainBinDir": "${userHome}/.platformio/packages/[email protected]/bin",
"internalConsoleOptions": "openOnSessionStart",
"svdPath": "${userHome}/.platformio/platforms/ststm32/misc/svd/STM32L4x2.svd",
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug"
}
}, |
+1, I tried a lot of different approaches. Adding anything other than autogenerated tasks to |
@leon0399 Please validate your JSON via https://jsonformatter.curiousconcept.com/ before saving. |
Have the same issue. Want to simply debug two devices at once. So i added a secondary entry for debugging a secondary environment. Its absolutely unusable for this use case as the launch.json is always overwritten. (My launch.json is valid json) |
Same here (again) loosing my cortex-debug sections, how can we stop platformio doing this, I don't event want to use the platformio debugger! |
Please ensure that your JSON is valid using https://jsonformatter.curiousconcept.com/ |
Could you share the RAW |
I have a problem with this as well, and I think I have isolated the issue for my specific case. My goal is to create a "PIO Attach" launch configuration. The way I am trying to achieve this, is to create an env in the platformio.ini file, so that I have both a debug and an attach env, which looks like the following:
Since my default env is esp32_debug, the launch.json file is generated with the following configurations: {
"version": "0.2.0",
"configurations": [
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug",
"executable": "/workspace/.pio/build/esp32_debug/firmware.elf",
"projectEnvName": "esp32_debug",
"toolchainBinDir": "/root/.platformio/packages/toolchain-xtensa-esp32/bin",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug"
}
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (skip Pre-Debug)",
"executable": "/workspace/.pio/build/esp32_debug/firmware.elf",
"projectEnvName": "esp32_debug",
"toolchainBinDir": "/root/.platformio/packages/toolchain-xtensa-esp32/bin",
"internalConsoleOptions": "openOnSessionStart"
},
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug (without uploading)",
"executable": "/workspace/.pio/build/esp32_debug/firmware.elf",
"projectEnvName": "esp32_debug",
"toolchainBinDir": "/root/.platformio/packages/toolchain-xtensa-esp32/bin",
"internalConsoleOptions": "openOnSessionStart",
"loadMode": "manual"
}
]
} I would then like to add a configuration to the launch.json file, that looks like this: {
"type": "platformio-debug",
"request": "launch",
"name": "PIO Attach",
"executable": "/workspace/.pio/build/esp32_attach/firmware.elf",
"projectEnvName": "esp32_attach",
"toolchainBinDir": "/root/.platformio/packages/toolchain-xtensa-esp32/bin",
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug"
}
} This all work. If I don't want to actively debug, I can upload the firmware via the PlatformIO pane, with the Upload task. If I then later want to attach the debugger, I can select PIO Attach in the debug pane, and a debug session will start without restarting the target device. However, when the platformio.ini file is updated/saved, the launch.json files is overwritten (as this thread is all about). I believe that this is handled by this file: https://github.com/platformio/platformio-core/blob/develop/platformio/project/integration/tpls/vscode/.vscode/launch.json.tpl. In this file, the code which is responsible for "saving" external configurations, looks for all configurations not of the type: "platformio-debug" (line 65). However, my PIO Attach configuration is of that type, and it therefore does not get saved, resulting in it getting overwritten. Is there a possibility to only look for the three launch configurations: PIO Debug, PIO Debug (skip Pre-Debug) and PIO Debug (without uploading)? |
@AnthonyDTU , could you file a new issue at https://github.com/platformio/platformio-core/issues ? We will implement this in the nearest release. |
Hi,
as already described by johnjiabinzhang in pio community posting VSCode IDE automatically generate of launch.json every time, the behavior breaks the official documented way how VSCode is configured.
Worse, in VSCode "Run" panel, there is also a GUI for adding custom settings to the project-specific launch.json, which are then - unexpectedly - overwritten when VSCode with platformio is restarted.
While I admit there is a warning in launch.json such as "do not edit this file", the provided links to the PIO documentaion do not help when custom launch.json tasks are needed instead of the PIO unified debugger.
Modifying the template file in PIO user config directory (.platformio/penv/lib/python3.8/site-packages/platformio/ide/tpls/vscode/.vscode) is also not a solution as this place is not shared with the project and as this is also not a place for permanent user or project-specific config.
My suggestion would be to only generate the .vscode/launch.json in case it does not yet exist and otherwise either ask the user to merge the settings or just append the PIO specific JSON objects to the launch.json.
Please let me know if I can be of any help implementing this.. however I have only rudimentary experience with the PIO project structure..
Regards, Ulrich
The text was updated successfully, but these errors were encountered: