platformio-vscode-ide icon indicating copy to clipboard operation
platformio-vscode-ide copied to clipboard

.vscode json files should use relative and env variables path

Open stoune opened this issue 5 years ago • 2 comments

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:

  1. It is not portable across machine
  2. 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.

stoune avatar Jan 02 '20 08:01 stoune

${env.HOME}/.platformio - the path for the Platformio installation.

stoune avatar Jan 02 '20 08:01 stoune

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.

zfields avatar Jun 07 '23 13:06 zfields