Vscode-remote-release: Remote-SSH: Opening terminal fails

Created on 13 Aug 2019  路  24Comments  路  Source: microsoft/vscode-remote-release

I previously reported similar behaviour to bug #565 (see https://github.com/microsoft/vscode-remote-release/issues/565#issuecomment-501690800)

This bug was deemed to be a duplicate of #1031, for which a fix has been applied in 1.37.0

However, I still have a problem, although it has now changed in behaviour.

I am trying to connect to a remote host, running CentOS (CentOS 7.6). Note that the login shell set up on the account is tcsh, but I can't change this (for various reasons).

The remote-SSH connection seems to succeed; remote servers are successfully installed, and I can browse and edit files on the remote host.

However, if I try to start a remote termnal, this immediately fails with the message:

"The terminal process command '/bin/bash' failed to launch (exit code: {2})"

Note that I can successfully ssh into the account using Windows SSH.

bug

All 24 comments

Does /bin/bash exist on your remote machine? I think I might know what's happening, you're getting the fallback shell resolved on the local side, not the remote side (ref for me later: this probably isn't good enough).

If so, I suspect this will workaround the issue until a fix goes is:

ln -s $SHELL /bin/bash

Actually /bin/bash _is_ present on the remote host.
So is/usr/bin/bash

My login shell on the remote is set to /bin/csh
But note this is actually a simlink to/bin/tcsh

Changing my login shell to /bin/bash doesn't make a difference unfortunately. I'm beginning to wonder whether the shell type is a bit of a red herring .. but it's weird that the setup of the remote connection works OK, just not the terminal.

When starting a new connection, the first two processes (downloading server, setting uf ssh tunnel) succeed, but then I get a

The terminal process command '/bin/bash' failed to launch (exit code: {0})

But I can see files and edit them.

Then, if I attempt to start up a new terminal I get:

The terminal process command '/bin/bash' failed to launch (exit code: {2})

If I change the default shell, this latter message is changed to (e.g):

The terminal process command '/bin/tcsh' failed to launch (exit code: {2})

The terminal process command '/bin/bash' failed to launch (exit code: {0})

Was that really a {0} not a {2}? I'm even more confused now as the executable should only show when that is {2}:

https://github.com/microsoft/vscode/blob/4e7348b81a4a7a3b8212ac9a7fd26ede6cde1907/src/vs/workbench/contrib/terminal/browser/terminalInstance.ts#L1060-L1066

Hi, Sorry .. been away ..

Yes, that's correct, when first trying to start up a session, I see

The terminal process command '/bin/bash' failed to launch (exit code: {0})

But subsequent attempts to open a terminal result in exit code {2}

I'm getting this as well. It's specific to one remote machine so it must be related to the setup of that box. I also think the shell is a red herring as it doesn't matter what I use /bin/{sh,bash,echo,tail,true,nano}. It always returns an exit code of {2}. It seems to be a general inability to launch processes using whatever method the internal terminal uses. There also doesn't seem to be any output in the Remote-SSH log except for perhaps an empty line with just a ">"

Editing files etc. however works as expected.

Any suggestions for debugging this further?

@Jordandev678 can you try enabling trace logging and checking the remote extension host log for details on the terminal launching? https://github.com/microsoft/vscode/wiki/Terminal-Issues#enabling-trace-logging

Nothing there looks particularly signifiant. Only these two lines are printed after attempting to launch a terminal.

[2019-11-05 16:52:24.799] [exthost] [debug] Terminal process launching on ext host {"executable":"/bin/bash","args":[],"cwd":"/home/jordandev678"} /home/jordandev678 216 19 <snipped large env dump>
[2019-11-05 16:52:24.800] [exthost] [trace] IPty#spawn /bin/bash [] {"name":"xterm-256color",
    "cwd":"/home/jordandev678",
    "env":{<snipped large env dump>},
    "cols":216,
    "rows":19,
    "experimentalUseConpty":false,
    "conptyInheritCursor":false
}

@Jordandev678 yeah nothing is sticking out as obviously wrong there... Are you connecting Linux -> Linux?

I agree with @Jordandev678 , it looks like one particular host.

I get exactly the same behaviour whether I connect to it from a Win10 host or a Linux (Ubuntu 18.04.2) host.

I have no problems in connecting from the Win10 host to the Ubuntu 18.04.2 host, which are both on the same local network.

Oh, yes, and the behaviour has not changed after upgrading to latest VS Code (1.40), and on the Win10 side, version 1903.

@Jordandev678 yeah nothing is sticking out as obviously wrong there... Are you connecting Linux -> Linux?

No, I'm Windows -> Linux. Other linux boxes work fine though which is why I think it must be something specific to the remote linux box setup.

I got the same issue.
Macos 10.14.6-> Linux Docker
Vscode: 1.40.2-f359dd69833dd8800b54d458f6d37ab7c78df520

I tried enable logs, but nothing about "open terminal" in outputs.
I tried to update the config item 'terminal.integrated.shell.linux' to any cmd I can thought
The outputs are always 'File not found'(gave a empty path) or 'exit {2}'(any binary, /bin/bash etc. even a simple a.out)
It seems that remote server can not invoke any binary by task "open remote terminal"

Hi, any progress on this issue ? I'm getting the same problem trying to connect Windows (2012 server 6.3.9600) -> Linux (RH 7.7). The terminal window show: Starting... and is not responding.

I ran into the same issue, but it started after a debug session went awry. Uninstalling and reinstalling the remote extensions was sufficient to fix the issues.

I have the same problem.
connect ssh Ubuntu 19.04-> Centos/
"The terminal process command '/bin/bash' failed to launch (exit code: {2})"
I tried to create symbolic links, edit / bin / bash-> usr / bin / bash, delete the configuration, reinstall vscode, use vscode insiders. It all doesn't work
Vscode: latest version

I have the same problem.
connect ssh Ubuntu 19.04-> Centos/
"The terminal process command '/bin/bash' failed to launch (exit code: {2})"
I tried to create symbolic links, edit / bin / bash-> usr / bin / bash, delete the configuration, reinstall vscode, use vscode insiders. It all doesn't work
Vscode: latest version

I'm also having this issue, but Win 10 -> RHEL 7. I've tried downgrading VS Code versions, deleting .vscode-server on the remote. Nothing has worked. Our sysadmin has tried connecting to another server on 1.41.1 and had success. He says nothing has changed on our RHEL 7 server, so I'm not sure if it's an issue with VS Code or our servers.

Initially I get exit code 0, then after trying to connect to a new terminal I get exit code 2. I've tried switching terminals, etc.

There's obviously a few different causes for this, but I think I might have found it in mine. I was digging around a strace for failing calls and found chown("/dev/pts/2"...) = -1 EPERM (Operation not permitted).

After more digging it looks like the administrator has devpts mounted without forcing a gid and glibc's grantpt() is attempting to 'fix' the permissions but can't successfully do so. Knowing that's potentially the problem I managed to find a number of broken applications (screen, tmux, etc) - all of which attempt to open a pty not just vs-code. It'd be interesting to see how many of the people in this thread are running into the same cause, a quick mount | grep devpts might provide some indication.

If that's the case (I'm off to pester the administrator) it's obviously not vs-codes problem. However perhaps as an enhancement this could be reported better if vs-code has the information? Even just knowing the error occurred while setting up a pty would have made this much easer to track down than exit code: {2}.

@Jordandev678 : I may be seeing something similar, but without quite enough linux-internal-smarts to know for sure. Client is windows, remote is a customized WindRiver system. Symptoms look similar, I can SSH into the system (via an intermediate SSH forwarder) and see the file system and edit files. /bin/sh is present (symlinked to /bin/bash, though) and works if I SSH into the system outside of VSCode. But when I attempt to open a terminal I get the process command '/bin/sh' failed to launch (Exit code {2}) error. Mount output below.

[me:~]$ mount | grep devpts
devpts on /dev/pts type devpts (rw,relatime,seclabel,gid=5,mode=620,ptmxmode=000)

Any updates on this? Also having the same issue going from Win10 -> CentOS 7.

Some info from the CentOS Bug Tracker: https://bugs.centos.org/view.php?id=17412

@Jordandev678 - were you able to 'pester the administrator' into any changes that made a difference?

Not sure if this will help but in my case I'm getting this issue when Jailed Shell is enabled on the account in cPanel. If I switch the shell back to normal shell the terminal opens fine.

Apologies for the late response - this dropped off my radar as I lost access to the system at issue with the working-from-home changes. However as it happens someone asked me for a hand with their server a couple days ago and it had exactly the same problem! They were fortunately happy for me to change it to set a gid temporarily to test if it fixes it and indeed it does.

I have no idea why these systems don't have that set by default; it's not a configuration I've seen before outside of these two but it apparently wasn't a one-off. What I have managed to find out is both are based of RHEL, and at least one of them was delivered setup like that from DELL. However as far as I'm aware RHEL sets a gid by default - so for some reason this is being removed?

@ljwobker Your mount shows it setting a gid (although I cant confirm if it's the right one in your setup) so I suspect this isn't your problem. These systems are not setting the gid at all, never mind to the correct group.

In summary; at least in my recent case it's not technically VSCode's fault. But the error messages VS code spits out when it can't start the terminal for one of the various reasons this can happen are not at all helpful in tracking down the cause. So more verbosity/insight into that would help if VSCode can provide it; even if it's not at fault.

So I had the same issue, and I was able to fix this by editing the settings.json file on the remote machine, the path to this is .vscode-server/data/Machine/settings.json
Inside this, write "terminal.integrated.shell.linux": "[path_to_shell]"

This information likely should exist in the vscode docs for remote development.

like @nmharmon8 , this happened to me after debugging. I couldn't open a terminal on the remote machine I was debugging on. There were some rogue processes running in cpptools I had to kill (see image). I then removed all files in ~/.vscode* on the remote machine. This fixed the problem.
image

Was this page helpful?
0 / 5 - 0 ratings