Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows 10 native bash does respond to tasks.json in VSCode

I am using the new native bash on Windows 10. I am trying to see any output in the VSCode console when I run a task that invokes the new bash. For example, this works because its using cmd:

tasks.json

{
    "version": "0.1.0",
    "command": "WHERE",
    "isShellCommand": true,
    "args": [ "bash" ],
    "showOutput": "always"
}

Which gives me the result I would expect, and it prints it to the VSCode console: C:\Windows\System32\bash.exe. This also shows me that cmd can see bash.exe.

Now, if I try to actually run bash from VSCode, I get nothing. No output whatsoever. If I were to start up cmd as standalone, the following command would work: bash -help. It would display the full bash help options inside the cmd window. But this tasks.json does not work:

{
    "version": "0.1.0",
    "command": "bash",
    "isShellCommand": true,
    "args": [ "-help" ],
    "showOutput": "always"
}

I initially thought that maybe the cmd that VSCode uses to call bash just wasn't displaying the output from bash. So I tried this task config to see if bash was even being executed, and it was not.

{
    "version": "0.1.0",
    "command": "bash",
    "isShellCommand": true,
    "args": [ "-c", "touch \"someFile.txt\"" ],
    "showOutput": "always"
}

If I run bash -c "touch someFile.txt" straight from cmd, it works as intended. If I try it using the above tasks.json, it produces nothing. It does not create the file, and it does not produce any output.

Do you guys have any ideas as to why this is?

like image 665
RestlessAPI Avatar asked Jan 21 '26 19:01

RestlessAPI


1 Answers

You need to replace "bash" with "c:\\Windows\\sysnative\\bash.exe"

like image 171
Rich Turner Avatar answered Jan 24 '26 10:01

Rich Turner