I have some shell scripts, which I would like to execute by name from code during debugging in Visual Studio Code. I need to extend $PATH environment variable to make it happened. Currently, I have following json in launch.json.
{
"name": "Debug-Linux",
"type": "go",
"request": "launch",
"mode": "debug",
"remotePath": "",
"port": 2345,
"host": "127.0.0.1",
"program": "${fileDirname}",
"env": {
"PATH": "$PATH:$(pwd)/../bin/"
},
"showLog": true
}
Also, I've tried
"env": {
"PATH": "${env.PATH}:$(pwd)/../bin/"
},
But, it does not work. How can I extend $PATH environment variable in launch.json in Visual Studio Code?
In Visual Studio Code, use shortcut Ctrl + Shift + P to open the Command Palette and type Open launch. json . And it will open the launch.
To create a launch. json file, click the create a launch. json file link in the Run start view. If you go back to the File Explorer view (Ctrl+Shift+E), you'll see that VS Code has created a .
Windows and Linux installations should add the VS Code binaries location to your system path. If this isn't the case, you can manually add the location to the Path environment variable ( $PATH on Linux). For example, on Windows, VS Code is installed under AppData\Local\Programs\Microsoft VS Code\bin .
You can browse and install extensions from within VS Code. Bring up the Extensions view by clicking on the Extensions icon in the Activity Bar on the side of VS Code or the View: Extensions command (Ctrl+Shift+X). This will show you a list of the most popular VS Code extensions on the VS Code Marketplace.
On Windows platform I found that Visual Studio Code seems to be case-sensitive. If the name of the variable is not spelled exactly as it is spelled on your machine, Visual Studio Code will ignore your variable from the launch.json.
For example, to properly set path
environment variable when it is spelled Path
, you would need to add the following to launch.json.
"env": {
"Path": "${env:Path};${workspaceFolder}\\node_modules\\.bin"
},
See Launch.json attributes and Variable Substitution in Visual Studio Code documentation for more information. Here what's mentioned there about the variable casing under Variable Substitution:
Note: Be sure to match the environment variable name's casing, for example ${env:Path} on Windows.
This is odd, because Windows is case-insensitive to the names of environment variables
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With