3

I'm working in vscode, and I want to build the chromium in tasks.json, but the build shell report error command not found. I use echo $PATH to see the environments variables in tasks.json. It seems like the build shell in vscode doesn't execute source ~/.bashrc, so it can't find environment variable, but the terminal in vscode is in working order. Could someone help me?

HaoxuanZhang
  • 33
  • 1
  • 3
  • My default integrated terminal setting came with `-l` such as `"path": "/usr/local/bin/bash", "args": ["-l"]` which according to [this](https://stackoverflow.com/questions/20499596/bash-shebang-option-l) should load your `.bashrc`. Have you tried that or is it set? – BadAtLaTeX May 14 '23 at 15:01

3 Answers3

4

I had the same issue and fixed it with the solution below

Solution For OSX with ZSH

Add a new file under /usr/local/bin/zsh-with-rc

#!/usr/bin/env zsh

source ~/.zshrc

/bin/zsh $@

Then run

chmod +x /usr/local/bin/zsh-with-rc

In settings.json add:

"terminal.integrated.automationProfile.osx": {
        "path": "/usr/local/bin/zsh-with-rc",
}

Solution For Linux With Bash

Add a new file under /usr/local/bin/bash-with-profile

#!/usr/bin/env bash

source ~/.bash_profile
source ~/.bashrc

/bin/bash $@

Then run

chmod +x /usr/local/bin/bash-with-profile

In settings.json add:

"terminal.integrated.automationProfile.linux": {
        "path": "/usr/local/bin/bash-with-profile",
}
Narek
  • 548
  • 6
  • 26
  • The OSX with ZSH solution worked great for me, thank you! – LiamM Nov 16 '22 at 17:32
  • This seems to make my tasks run without any arguments. For instance `"command": "echo hello"` doesn't show any output, but without this setting it correctly prints 'hello'. I'm on Linux with Bash. – Jespertheend Apr 03 '23 at 09:49
1

Just like @Narek I had to create an automation profile. However the Linux version is:

"terminal.integrated.automationShell.linux": "/usr/local/bin/zsh-with-rc",

It is most definitely a bug because for me, my build tasks were working fine, until suddenly some build tasks failed, while others were still working (EVEN THOUGH invoking the same command). This might be since the most recent update (1.79.2) For me it was catkin_make .

Steve
  • 21
  • 2
0

Add "terminal.integrated.shell.linux": "/bin/bash" in settings.json

HaoxuanZhang
  • 33
  • 1
  • 3