-
Notifications
You must be signed in to change notification settings - Fork 29.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Task not executing bash, yet echoed command works fine in cmd #6579
Comments
Lets investigate for May. But no promise :-) |
Sure, I can imagine this is fairly low priority as far as bugs are concerned - but it sure would be a nice feature to use Keyboard shortcuts to perform various tasks in Bash on Ubuntu on Windows :-) |
This simple example doesn't work either: {
"version": "0.1.0",
"command": "bash.exe",
"isShellCommand": true,
"showOutput": "always",
"echoCommand": true,
"args": [
"-c", "echo Hello World"
]
} it produces:
Looks like bash is not known in an spawned cmd.exe. Interestingly executing this in a command prompt
works |
Trying this {
"version": "0.1.0",
"command": "C:\\Windows\\System32\\bash.exe",
"showOutput": "always",
"echoCommand": true,
"args": [
"-c", "echo Hello World"
]
} doesn't work either. It prints:
|
This is either a node problem or a general bash problem. Trying var cp = require('child_process');
cp.exec('bash -c "echo Hello World"', function(error, out, err) {
if (error) {
console.log(error);
} else {
console.log(out);
console.log(err);
}
}); doesn't work either in a native node environment. No further action planned for May. Need to see if spawning bash from a different programming language (e.g. C#) works |
I got this working without any issues when answering his So question. http://stackoverflow.com/a/37378311/1156119 Windows 10 64 bit, just installed. I have a feeling now that it would have been git bash that it was actually running in. |
The Git Bash bit makes sense - but kinda defeats what I'm trying to do here; segregate dev tooling to Ubuntu on Windows. |
I had trouble getting the integrated terminal running |
I had an issue similar to this when trying to launch debug with bash. What I found what that VSCode is 32 bit and bash.exe is only available in the 64 bit system32 folder. 32 bit apps get redirected to the SysWOW64 folder. As a work around you can copy bash.exe from System32 to the SysWOW64 folder and VSC will be able to find it. |
I tried your suggested workaround before and could not manage to get it to call bash for this purpose. |
@Aigeec: Unfortunately it doesn't work. Output is empty when I try to run any bash command using task. My tasks:
@dbaeumer @JasonDunbar any luck with solving this problem? |
Unfortunately still no solution... I gave up and go to Bash direct, instead of trying to call from within VSCode. |
For what it's worth, having same problem from within Python. I can run bash commands manually from the command line but that's all.
|
...and still no further on what the plan is here or whether or not it will ever get a planned release milestone. @dbaeumer any news? |
I retried it and trying to spawn bash.exe from the Linux subsystem still fails on node. So there is little VS Code can do to fix this. Would be interesting to know whether bash.exe from the Linux subsystem can be spawn in C# or Python to understand where this is a node or a bash.exe problem. |
Any news on this issue please? Do we require a 'WSL task runner'? |
@Tyriar pointed out to me that we should try using |
You can run a task in the windows bash via bat/sh proxies. So for the python example above you could set up your task as: {
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "0.1.0",
"command": "task.bat",
"isShellCommand": true,
"showOutput": "always",
"tasks": [
{
"taskName": "Run python in bash",
"suppressTaskName": true,
"args": [
"python",
"${relativeFile}"
]
}
]
} Note: This uses ${relativeFile} not file. File passes a windows path and doesn't work. The task.bat file would be a one-liner: C:/Windows/sysnative/bash.exe ./task.sh %* Referring to a two-liner: #!/bin/bash
exec "$@" Output is for a file public/hello.py containing
|
I am also getting this when calling an external batch file that is then calling bash, e.g.:
However if I call the batch script from the integrated terminal it runs correctly! from a quick search on google, error 0x80070057 is caused by using legacy console... Is VS code using a legacy console for tasks?! |
you can simply use isShellCommand: true which will pick the default shell. If you want to control the shell you need to specify it. If you want to make this OS specific you can use the OS specific properties windows, linux, ... |
Is there another way to select the shell than prepending |
Yes you can do the following on latest
However escaping was still broken. I fixed a bug there yesterday, |
Win Build: 15063.250
|
add the following line to
and then set
The whole thing is equivalent to
|
@tl1u16 with the new task 2.0.0 this should be written as follows: {
"version": "2.0.0",
"tasks": [
{
"taskName": "build",
"command": "make clean all",
"type": "shell",
}
]
} |
@dbaeumer I'm using vscode latest version (1.15) and using task 2.0.0. Yet, I can only make args work the way suggested by @tl1u16 (yes, using the now deprecated suppressTaskName and the extra quotes). I've tried both:
and
both runs as if no argument was provided. I also tested with echo ( |
@andre-ss6 this is discussed in #28036 and a problem with bash or the Linux subsystem. We are looking into how to best fix this. |
I had similar problem with executing commands in my default git/bash shell (VSC 1.15.1; Windows 10 Pro - x64) and @tl1u16 hint with 1. With changed terminal integrated shellUser Settings:
.vscode/tasks.json:
2. Without messing in default terminal integrated shell.vscode/tasks.json:
|
The problem with args in a command when executing in bash (both git and WSL) got addressed for 1.16. So the ""command" trick should no longer be needed. |
I confirm that in VSC 1.6 the problem no longer exist and use of |
I tried this today with 1.23.0. {
"version": "2.0.0",
"tasks": [
{
"label": "pwd",
"type": "shell",
"options": {
"shell": {
"executable": "C:\\Windows\\sysnative\\bash.exe",
"args": [
"-c"
]
}
},
"command": "pwd"
}
]
} This does not work, it just hangs without any output. But there are many way to make it work now.
But I still wonder why the way I tried first does not work. |
I was able to reproduce this. Interestingly using @Tyriar can you comment on why |
Set any arbitrary string that does not exist as I think vs code just can't find the executable? BTW, I think vs code should give an error message in case of the executable can't be found, instead of just hanging. |
Oh, I found However, why |
sysnative should only ever be used on 32-bit VS Code on a 64-bit system, I wrote about this here: http://www.growingwiththeweb.com/2017/08/windows-wow64.html
Because the terminal has logic to translate sysnative to system32 when running a 64-bit executable, this was to help with migration when 64-bit code was introduced. |
@Tyriar thanks. Can I somehow reuse that code when creating a terminal ? |
It's here: You're already calling it from here: |
I do call |
Integrated the code into the terminal task runner. @Tyriar thanks. |
Based on the discussion it seems like this might already be fixed by multiple changes. Anyone still having this issue? |
This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines. Happy Coding! |
I've been setting up Ubuntu user mode with node and npm and wanted to run a task from Visual Studio code to call gulp to transpile Typescript to Javascript in that environment.
If from the command line (cmd.exe) I execute
bash -c "gulp"
then it works exactly as I would expect it to... Running the default task as defined in my gulpfile.js.But if I try and set up a task in tasks.json, it tells me it's running the exact same command, but there's no output and no javascript generated.
Steps to Reproduce:
Set up a task to run bash like so:
{
"version": "0.1.0",
"command": "bash",
"isShellCommand": true,
"showOutput": "always",
"echoCommand": true,
"args": [
"-c"
],
"tasks": [{
"taskName": "Gulp Typescript Job",
"suppressTaskName": true,
"args": [
""gulp""
],
"isBuildCommand": true,
"problemMatcher": "$gulp-tsc",
"showOutput": "always",
"echoCommand": true
}]
}
Edit: formatting (still not great, sorry)
The text was updated successfully, but these errors were encountered: