代码之家  ›  专栏  ›  技术社区  ›  RWDJ

在VS代码任务中使用.bash\u profile函数

  •  0
  • RWDJ  · 技术社区  · 6 年前

    我在VS代码中定义了以下任务:

    "label": "build",
    "type": "shell",
    "command": "opengl++ Interpolate.cpp"
    

    opengl++() 是中定义的bash函数 ~/.bash_profile 打开终端

    >执行任务:opengl++Interpolate.cpp<

    /bin/bash:opengl++:未找到命令
    终端进程终止,退出代码:127

    "label": "build",
    "type": "shell",
    "command": "source ~/.bash_profile && opengl++ Interpolate.cpp"
    

    解决了这个问题,这使它看起来像终端是不正确的。我尝试删除VS代码上的所有用户设置,但没有效果。

    这不是一个可行的解决办法。明确要求采购似乎很危险 . 在使用python(pyenv)的构建任务和类似的使用 ~/.bash\u配置文件 正确编译而忘记显式源代码。

    ~/.bash\u配置文件 在VS代码shell任务中工作而不预先添加 source ~/.bash_profile

    1 回复  |  直到 6 年前
        1
  •  1
  •   RWDJ    6 年前

    .vscode . 然后,使用类似于以下命令的命令在任务中生成脚本:

    source .vscode/scripts/build.sh
    

    像这样的线条 set -e source ~/.bash_profile 在脚本中可以包括其他内容,我们有一个更干净的 tasks.json .

        2
  •  1
  •   Ben Hansell    5 年前

    我在Linux和Linux上也遇到了类似的问题 this GitHub issue 帮助了我。

    "terminal.integrated.shellArgs.osx": [ "-l" ]
    

    添加到settings.json。