VSCode 构建任务命令未找到

Hao*_*ang 5 build chromium visual-studio-code

我正在 vscode 中工作,我想在tasks.json 中构建chromium,但是构建shell 报告 error command not found。我使用 echo $PATH 来查看tasks.json 中的环境变量。看起来 vscode 中的构建 shell 没有执行source ~/.bashrc,因此找不到环境变量,但 vscode 中的终端正常工作。有人可以帮助我吗?

Nar*_*rek 6

我遇到了同样的问题并使用下面的解决方案修复了它

带有 ZSH 的 OSX 解决方案

在下面添加一个新文件/usr/local/bin/zsh-with-rc

#!/usr/bin/env zsh

source ~/.zshrc

/bin/zsh $@
Run Code Online (Sandbox Code Playgroud)

然后运行

chmod +x /usr/local/bin/zsh-with-rc
Run Code Online (Sandbox Code Playgroud)

添加settings.json

"terminal.integrated.automationProfile.osx": {
        "path": "/usr/local/bin/zsh-with-rc",
}
Run Code Online (Sandbox Code Playgroud)

使用 Bash 的 Linux 解决方案

在下面添加一个新文件/usr/local/bin/bash-with-profile

#!/usr/bin/env bash

source ~/.bash_profile
source ~/.bashrc

/bin/bash $@
Run Code Online (Sandbox Code Playgroud)

然后运行

chmod +x /usr/local/bin/bash-with-profile
Run Code Online (Sandbox Code Playgroud)

添加settings.json

"terminal.integrated.automationProfile.linux": {
        "path": "/usr/local/bin/bash-with-profile",
}
Run Code Online (Sandbox Code Playgroud)