gpt4 book ai didi

debugging - 如何在 Visual Studio Code 中的 launch.json 中扩展 $PATH?

转载 作者:行者123 更新时间:2023-12-03 07:55:22 24 4
gpt4 key购买 nike

我有一些 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 环境变量?

最佳答案

视窗 我发现 Visual Studio Code 似乎区分大小写。如果变量名称的拼写与您机器上的拼写不完全相同,Visual Studio Code 将忽略 launch.json 中的变量。

例如,正确设置 path拼写时的环境变量 Path ,您需要将以下内容添加到launch.json。

"env": {
"Path": "${env:Path};${workspaceFolder}\\node_modules\\.bin"
},

Launch.json attributesVariable Substitution在 Visual Studio Code 文档中了解更多信息。
这里提到了关于 Variable Substitution 下的可变大小写的内容。 :

Note: Be sure to match the environment variable name's casing, for example ${env:Path} on Windows.



这很奇怪,因为 Windows 对环境变量的名称不区分大小写

关于debugging - 如何在 Visual Studio Code 中的 launch.json 中扩展 $PATH?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47662998/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com