Skip to content

Integrated terminal fails with native exception / forkpty(3) failed #4233

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

Closed
ljwobker opened this issue Dec 25, 2020 · 15 comments
Closed

Integrated terminal fails with native exception / forkpty(3) failed #4233

ljwobker opened this issue Dec 25, 2020 · 15 comments
Assignees
Labels
*not-reproducible Issue cannot be reproduced by VS Code Team member as described ssh Issue in vscode-remote SSH

Comments

@ljwobker
Copy link

  • VSCode Version: 1.52.1
  • Local OS Version: Windows 10 Professional
  • Remote OS Version: Linux node0_RP1_CPU0 4.8.28-WR9.0.0.20_cgl
  • Remote Extension/Connection Type: SSH

Steps to Reproduce:

  1. Connect to remote system. VSCode successfully installs the server remotely, but will not launch a terminal.
  2. The following error message appears:
    The terminal process failed to launch: A native exception occurred during launch (forkpty(3) failed.).

Details:
As far as I can tell, the only impacted component is the terminal. The remote filesystem can be seen, files can be edited, etc. I feel as if there must be something unique about this remote, but I can't find any other meaningful debugging or logging output. Would appreciate thoughts on what else to look at / report...

@github-actions github-actions bot added the ssh Issue in vscode-remote SSH label Dec 25, 2020
@Aurora28
Copy link

Aurora28 commented Jan 5, 2021

Hi, I encountered the same problem but suddenly the error was eliminated from nowhere and the terminal can run successfully. It's kind of weird, so I guess the network stability might matter a lot in this case.

Also What I did:
Open the Settings -> search:terminal.integrated -> find the "Automation Shell: Linux" -> choose "Edit in settings.json"

However, before I did any other further steps, the problem disappeared. So I highly suspect this "forkpty(3) failed" error is closely associated with the internet connection. Just have a try later may help. Good luck :)

@ljwobker
Copy link
Author

ljwobker commented Jan 5, 2021

It's something related to that particular machine type. Other "pure" linux machines in the same lab (i.e. network connectivity) work fine - there's something specific to this distribution or setup, but I don't know what other debugging tools (either on the vscode or linux host side) to look at.

@Josersanvil
Copy link

I'm having this same problem, same VSCode version and OS, my remote host is on Ubuntu 18.04.
It started happening after VStudio Code crashed when the terminal was handling a large download process and writing a lot of messages to stdout. Now I can't open the terminal on the remote host.

It doesn't seem to have nothing to do with my network connection either.

@Josersanvil
Copy link

I managed to fix it by connecting via SSH to the remote host and manually deleting the ~/.vscode folder, then i set up the connection again on VS Code and it worked fine.

@Tushar1729-k
Copy link

Tushar1729-k commented Jan 21, 2021

Steps to reproduce:

  1. I had an infinite loop and a single letter kept printing to stdout and the terminal.
  2. Control-c does not stop the process, nor does pressing the trash can button. VSCode simply freezes. It gives a prompt saying you can wait or reopen the window. Upon reopening, this error appears.
  3. The same error message appears as OP.

@Josersanvil I tried your fix and unfortunately it did not work for me.

@Tushar1729-k
Copy link

FIX
Credit: My TA Kevin
Similar to what @Josersanvil says, delete the ~/.vscode-server folder on the remote host. (It is a hidden folder, so unhide it.)
I added the extra step of reinstalling the Microsoft Remote - SSH extension.
Terminal is happy now.

@tonymurray
Copy link

I had similar issue while connecting to a linux host via ssh -- in a chroot environment. [forkpty(3)] failed. I found this: https://unix.stackexchange.com/questions/390997/ptys-not-working-in-chroot-under-lxc. The solution for me was to get pty working within the chroot [ref: https://man7.org/linux/man-pages/man7/pty.7.html] - by creating /chroot/dev device files [ref: https://tldp.org/LDP/Linux-Filesystem-Hierarchy/html/dev.html]. This involved recreating /dev/ptmx and /dev/pts/* (refer to actual (non-chroot) /dev folder). Guide: https://www.lifewire.com/linux-system-administrators-guide-2203428. Regarding permissions: https://lwn.net/Articles/684005/

@Tyriar
Copy link
Member

Tyriar commented Feb 22, 2021

This is where that exception comes from: https://github.com/microsoft/node-pty/blob/87990b27a51423efcd6aa55f32a7b02a972201a7/src/unix/pty.cc#L717

I don't think there's anything I can do on my side here, it's either:

  1. A problem with file permissions inside the server install directory as indicated by deleting and reconnecting fixing the issue
  2. An OS-level issue out of the scope of vscode

@Tyriar Tyriar assigned roblourens and unassigned Tyriar Feb 22, 2021
@daniel-oelert
Copy link

I have the exact same issue. So far I have tested disabling the TypeScript extension (there were related errors, due to not being able to fork), which didn't help. I even did a clean reinstall of Ubuntu 18.04 Server, with just a user added and ssh configured, nothing else. It also affects more than just VSCode. It renders the server unable to fork at all at times, so i can not use ssh from another terminal to connect to it either. I can easily reproduce the error, can I provide additional information to solve this issue?

@prafiny
Copy link

prafiny commented Mar 31, 2021

I have been having the same problem on a Linux 4.19.0-14-amd64 #1 SMP Debian 4.19.171-2 (2021-01-30) x86_64 GNU/Linux. Turned out there were wrong /dev/pts permission issues and this was solved by chmoding a+x. Anyways, debugging was tedious for this one as the ERRNO for forkpty wasn't displayed.

@roblourens roblourens added the *not-reproducible Issue cannot be reproduced by VS Code Team member as described label Apr 5, 2021
@ljwobker
Copy link
Author

ljwobker commented Apr 7, 2021

A colleague was able to track this down (finally). On the target machine in question the permissions for /dev/pts/ptmx were set to something that was unfriendly to VSCode. Changing these permissions allowed the terminal to launch without problems. This level of OS-gookery is beyond my knowledge, so if anyone feels like posting as to why this actually helps that would be great...

[/home/luser]$ ls -l /dev/pts/ptmx
c---------. 1 root root 5, 2 Mar 27 01:22 /dev/pts/ptmx
## no worky!

[/home/luser]$ chmod o+rw /dev/pts/ptmx

[/home/luser]$ ls -l /dev/pts/ptmx
c------rw-. 1 root root 5, 2 Mar 27 01:23 /dev/pts/ptmx
## works now!

@readren
Copy link

readren commented Apr 21, 2021

I have the exact same problem with VSC Version 1.55.2 and Remote SSH version 0.65.4 when connecting from windows 10 to a virtual Centos 7 (Linux 3.10.0-1127.19.1.el7.x86_64) hosted by GCP, using IdentityFile authentication.
It didn't happen the first time I connected, but all the following times.
It is worth clarifying that I am asked to enter the passphrase twice: after "connect to host" and after pressing the "open folder" button.
Neither deleting the "~/.vscode-server" folder nor the applying the "cmod o+rw /dev/pts/ptmx" command did solve it.

@parish-shrestha
Copy link

I'm getting this same error.
VSC Version 1.56
Connecting from Windows 10 to a remote host Centos 8 using password.

@matteocostantini
Copy link

I'm getting this same error.
VSC Version 1.56.2
Connecting from Windows 10 to a remote host Debian 10 using private key. The user is jailed with jailkit.

@github-actions github-actions bot locked and limited conversation to collaborators May 23, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
*not-reproducible Issue cannot be reproduced by VS Code Team member as described ssh Issue in vscode-remote SSH
Projects
None yet
Development

No branches or pull requests

13 participants