我有一些 shell 脚本,我想在 Visual Studio Code 中调试期间通过代码名称执行这些脚本。我需要扩展 $PATH 环境变量才能实现它。目前,我在 launch.json 中有以下 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
}
另外,我也尝试过
"env": {
"PATH": "${env.PATH}:$(pwd)/../bin/"
},
但是,它不起作用。如何在 Visual Studio Code 中扩展 launch.json 中的 $PATH 环境变量?
On Windows平台我发现Visual Studio Code似乎是区分大小写的。如果变量名称的拼写与您计算机上的拼写不完全一样,Visual Studio Code 将忽略 launch.json 中的变量。
例如,要正确设置path
环境变量拼写时Path
,您需要将以下内容添加到 launch.json。
"env": {
"Path": "${env:Path};${workspaceFolder}\\node_modules\\.bin"
},
See Launch.json 属性 https://code.visualstudio.com/docs/editor/debugging#_launchjson-attributes and 变量替换 https://code.visualstudio.com/docs/editor/debugging#_variable-substitution有关详细信息,请参阅 Visual Studio Code 文档。
这里提到了下面关于可变大小写的内容变量替换 https://code.visualstudio.com/docs/editor/debugging#_variable-substitution:
注意:请务必匹配环境变量名称的大小写,例如 Windows 上的 ${env:Path}。
这很奇怪,因为 Windows 对环境变量名称不区分大小写
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)