我在 VS Code 中定义了以下任务:
"label": "build",
"type": "shell",
"command": "opengl++ Interpolate.cpp"
中opengl++()
定义的 bash 函数在哪里~/.bash_profile
?我正在使用 MacOS High Sierra,该功能在Terminal.app 中有效。执行这个任务得到:
> 执行任务:opengl++ Interpolate.cpp <
/bin/bash: opengl++: command not found
终端进程以退出代码终止:127
将任务更改为:
"label": "build",
"type": "shell",
"command": "source ~/.bash_profile && opengl++ Interpolate.cpp"
解决了这个问题,这使得终端似乎没有正确采购。我尝试删除 VS Code 上的所有用户设置无济于事。
这不是一个可行的解决办法。要求明确采购似乎很危险~/.bash_profile
。在使用 python (pyenv) 和类似编译器的构建任务时,这似乎可能会导致问题,这些编译器~/.bash_profile
用于正确编译而忘记显式源代码。
如何使用定义的函数~/.bash_profile
在 VS Code shell 任务中工作而不预先添加source ~/.bash_profile
?
在.vscode
. 该脚本可以包含有组织且复杂的命令。然后,使用类似于以下命令的任务在任务中获取脚本:
source .vscode/scripts/build.sh
般的线条set -e
和source ~/.bash_profile
除其他事项外,可以包含在脚本,我们有一个更干净tasks.json
。
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句