VSCode build task command not found
Asked Answered
C

4

5

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?

Clownery answered 10/6, 2021 at 8:17 Comment(1)
My default integrated terminal setting came with -l such as "path": "/usr/local/bin/bash", "args": ["-l"] which according to this should load your .bashrc. Have you tried that or is it set?Adulterant
C
6

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",
}
Continually answered 1/3, 2022 at 16:39 Comment(3)
The OSX with ZSH solution worked great for me, thank you!H
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.Toleration
how about windows user?Goatsucker
S
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 .

Scary answered 30/6, 2023 at 8:36 Comment(0)
C
0

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

Clownery answered 16/6, 2021 at 6:39 Comment(1)
I think this isn't a solution that will work for all usersSciurine
O
0

Just use .zshenv to set your PATH variables. .zshenv is always sourced while .zshrc is sourced only for interactive shells. You can check Z-Shell's User's Guide for more info.

Outfall answered 8/12, 2023 at 12:59 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.