Vscode: Integrated terminal closes immediately when set to Windows Bash

Created on 3 Aug 2016  Â·  19Comments  Â·  Source: microsoft/vscode

  • VSCode Version: 1.3.1
  • OS Version: Windows 10.0.14393

Steps to Reproduce:

  1. Enable user setting "terminal.integrated.shell.windows": "C:\\Windows\\System32\\bash.exe"
  2. Open integrated terminal
needs more info

Most helpful comment

Thank you for the help @Tyriar

All 19 comments

Seeing this as well. I tried to switch back to cmd.exe and the same thing happens.

To clarify, in my case, switching back to cmd/git-bash is successful. But whenever I try pointing to Windows Bash, it fails.

In my case,None of following works:
"c:\\Windows\\System32\\bash.exe"
"c:\\Windows\\sysnative\\bash.exe"
"C:\\Program Files\\Git\\bin\\bash.exe"

Same thing in Atom editor.
Orz

@mzvast Does switching back to cmd.exe work for you?

@brianblakely Nope. Either in Atom.
default value "terminal.integrated.shell.windows": "C:\\WINDOWS\\system32\\cmd.exe"
T_T

Following is the debug info in VScode:

terminalInstance.ts:55 Integrated terminal exited with code 1
(anonymous function) @ terminalInstance.ts:55
emitTwo @ events.js:100
emit @ events.js:185
ChildProcess._handle.onexit @ internal/child_process.js:204

Following is debug info in Atom:
C:\Users\mzvast\AppData\Local\atom\app-1.9.1\resources\app.asar\src\task.js:52 Unable to start terminal process. Win32 error code: 267 Error: Unable to start terminal process. Win32 error code: 267
at Error (native)
at Server. (C:\Users\mzvast.atom\packages\platformio-ide-terminal\node_modules\pty.js\lib\pty_win.js:67:9)
at emitOne (events.js:90:13)
at Server.emit (events.js:182:7)
at Pipe.onconnection (net.js:1439:8)
(anonymous function) @C:\Users\mzvast\AppData\Local\atom\app-1.9.1\resources\app.asar\src\task.js:52
(anonymous function) @C:\Users\mzvast\AppData\Local\atom\app-1.9.1\resources\app.asar\src\task.js:126
module.exports.Emitter.simpleDispatch @ C:\Users\mzvast\AppData\Local\atom\app-1.9.1\resources\app.asar\node_modules\event-kit\lib\emitter.…:25
module.exports.Emitter.emit @ C:\Users\mzvast\AppData\Local\atom\app-1.9.1\resources\app.asar\node_modules\event-kit\lib\emitter.…:125
(anonymous function) @ C:\Users\mzvast\AppData\Local\atom\app-1.9.1\resources\app.asar\src\task.js:78emitTwo @ events.js:100
emit @ events.js:185
handleMessage @ internal/child_process.js:718
channel.onread @ internal/child_process.js:444

@mzvast Hmm, does that mean something possibly with Electron? Aren't they both built on Electron?

@brianblakely
Yep,they are electron-based.
Interestingly, when I launch terminal with path C:\windows\system32\bash.exe on WebStorm(which is a java-based IDE),it prompt an error thatjava.io.IOException: Couldn't create PTY

Interestingly, if I set ComSpec to %windir%\system32\cmd.exe then vscode behaves just like when I set it to C:\WINDOWS\system32\bash.exe. If I set ComSpec to C:\WINDOWS\system32\cmd.exe then cmd.exe works fine.

I wrote up some documentation on configuring the terminal for Windows recently https://code.visualstudio.com/docs/editor/integrated-terminal#_configuration

Try using c:\\Windows\\sysnative\\bash.exe, and make sure it's installed and you can access it in a regular cmd.exe prompt.

@Tyriar Interesting. If I do that, then the CTRL+`` works, butCTRL+SHIFT+C` does not.

@mattblang that's because c:\Windows\sysnative\bash.exe is a console program instead of a full-blown terminal, you need to run it through cmd.exe. You may be able to write a wrapper batch script that runs cmd.exe and bash.exe inside that, then use that as the external terminal.

@Tyriar Should c:\windows\system32\bash.exe not work for both of the hotkeys?

Edit: Strike that, it would also be a console program I am guessing. So is there no way to hook vscode straight into the new bash shell that was in the anniversary update?

Edit: Strike that again, you can, like you mentioned, hook CTRL+`` into it, but onlyCTRL+SHIFT+C` if it was a full-blown console. Got it now, thanks!

Thank you for the help @Tyriar

@mattblang don't know enough about it, but my assumption is that bash.exe needs cmd.exe's UI to be able to run. If you can get it working please share and I'll add to the docs :smiley:

So, I'm not on the anniversary update, and pointing to bash.exe didn't work, but doing the below seems to be working for me (only just tried it, haven't used it extensively):

// settings.json
{
    "terminal.integrated.shell.windows": "C:\\Windows\\System32\\cmd.exe",
    "terminal.integrated.shellArgs.windows": [
        "/k",
        "C:\\Program Files\\Git\\bin\\bash.exe"
    ]
}

@jamiebarrow that's git bash, the version of bash shipped with the git installer, this issue is specifically about the Bash on Ubuntu (WSL) executable.

@Tyriar Ah okay, I don't have the anniversary edition installed, though was wondering if perhaps that would be a workaround if people are getting the same issue I had - trying to run git bash on Win 10 in integrated terminal was giving me the same issue, terminating immediately. Thought it was worth sharing :)

@jamiebarrow perhaps, thanks for sharing :smiley:

I came here with this issue, bash integrated terminal just immediately closing upon opening the terminal. I read this thread and then tried opening cmd and running bash. I then realised I didn't have developer mode turned on, and hadn't installed bash correctly. I fixed it by switching developer mode on, and installing bash by calling it from cmd.

I originally went to windows features, switched on the linux subsystem, did a restart and then "installed" bash by clicking start, typing bash, and clicking on it, based on some older instructions I read. Then modified the vscode settings. Clearly the wrong process to set it up. I'm just adding this comment because other people might have done the same.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

sijad picture sijad  Â·  3Comments

curtw picture curtw  Â·  3Comments

chrisdias picture chrisdias  Â·  3Comments

shanalikhan picture shanalikhan  Â·  3Comments

v-pavanp picture v-pavanp  Â·  3Comments