platformio-vscode-ide
platformio-vscode-ide copied to clipboard
.vscode json files should use relative and env variables path
Auto-generated files .vscode/c_cpp_properties.json .vscode/launch.json contains absolute path, for example:
"configurations": [
{
"type": "platformio-debug",
"request": "launch",
"name": "PIO Debug",
**"executable": "/Users/username/Projects/projname/.pio/build/esp32dev/firmware.elf",
"toolchainBinDir": "/Users/username/.platformio/packages/toolchain-xtensa32/bin",**
"preLaunchTask": {
"type": "PlatformIO",
"task": "Pre-Debug"
},
"internalConsoleOptions": "openOnSessionStart"
},
The absolute path has two issues:
- It is not portable across machine
- It is expose username in the path if I commit them into public git repo
VS Code supports a bunch of variables which should make these path more portable. ${workspaceFolder} - will be a folder where project resides. ${workspaceFolder} - the path for the Platformio installation.
${env.HOME}/.platformio - the path for the Platformio installation.
3 years!? Come on, guys. This is so easy to fix, and this is such a nuisance.
You must already be using variables to create the files in the first place. Just make them string literals instead of variables and the whole thing should "just work".
launch.json
{
...
"executable": "${workspaceFolder}/.pio/build/<board>/firmware.elf",
...
"toolchainBinDir": "${env:HOME}/.platformio/packages/<toolchain>/bin",
...
}
This prevents a team from easily working on a shared code base, because we cannot check in the .vscode
folder.