question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Remote-SSH when connecting to Windows machine: The terminal process failed to launch

See original GitHub issue

I haven’t tried SSH from this machine in a couple of weeks, but it used to work. Now each time I try to create a terminal I see:

image

And this is in the console:

The terminal process failed to launch: A native exception occurred during launch (Unable to start terminal process: CreateProcess failed)```

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:12 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
carlossanlopcommented, Aug 31, 2021

I can reproduce, and I have somewhat similar environment as @eamodio .

I’m an employee, feel free to contact me on Teams for more info or to show you a repro. @Tyriar @TylerLeonhardt

For me, it also seems the issue is that the remote PowerShell instance cannot be invoked. I can only make my remote shell work if I use a cmd shell.

Environment

  • Client machine:
    • Arch: ARM64 (Surface Pro X)
    • OS: Windows 11 Version 21H2 (Build 22000.168)
    • VS Code About info:
Version: 1.59.1 (system setup)
Commit: 3866c3553be8b268c8a7f8c0482c0c0177aa8bfa
Date: 2021-08-19T11:56:07.791Z
Electron: 13.1.7
Chrome: 91.0.4472.124
Node.js: 14.16.0
V8: 9.1.269.36-electron.0
OS: Windows_NT ia32 10.0.22000
  • Remote machine:
    • Arch: x64
    • OS: Windows 10 Version 21H1 (Build 19043.1110)
    • PowerShell: 7.1.4.0 installed via Microsoft Store
    • VS Code About info (not sure if relevant or if it affects this issue, but here it is):
Version: 1.60.0-insider (system setup)
Commit: c08913337cb8b95493be8e99d62e0b3241563f6b
Date: 2021-08-19T05:15:46.693Z
Electron: 13.1.8
Chrome: 91.0.4472.164
Node.js: 14.16.0
V8: 9.1.269.39-electron.0
OS: Windows_NT x64 10.0.19043

What I tried

In my client machine (ARM64), I opened Settings -> Remote [SSH] -> Terminal, then opened the settings.json file. There are 3 settings items that I can configure:

  • terminal.integrated.automationShell.windows
  • terminal.integrated.defaultProfile.windows
  • terminal.integrated.profiles.windows

The autocomplete offers 3 possible values for any of those 3 items: “PowerShell”, “Command Prompt”, “Git Bash”.

The only one that does not work is PowerShell. I get the same error message:

The terminal process failed to launch: A native exception occurred during launch (Unable to start terminal process: CreateProcess failed).

I am not sure if this is relevant, but as I mentioned in my environment info, the PowerShell I installed comes from the Microsoft Store, so it’s not installed in C:\Program Files\, but rather in the folder where all the App Execution Aliases live: %LOCALAPPDATA%\Microsoft\WindowsApps.

With this info, I also tried to create my own custom profile, like this:

"terminal.integrated.profiles.windows": {
     ... // Here are PowerShell, CommandPrompt and Git Bash defined
     ...,
        "Custom": {
            "path": "${Env:LOCALAPPDATA}\\Microsoft\\WindowsApps\\pwsh.exe",
            "icon": "terminal-powershell"
        }

But this did not work: When I try to create a new shell instance, the “Custom” option does not show up. I assume App Exec Aliases cannot be executed from VS Code.

Workaround

Set terminal.integrated.defaultProfile.windows to “Command Prompt”, and you should be able to connect remotely.

Unfortunately, Application Execution Aliases also can’t be executed from within cmd (the pwsh.exe installed from Microsoft Store cannot be invoked). So you’re stuck using cmd.

-OR-

Uninstall the Microsoft Store version of PowerShell, and instead download the MSI installer from here: https://github.com/PowerShell/PowerShell

0reactions
matty-rcommented, Feb 1, 2022

I’m getting this issue. On Linux with Remote-SSH into Windows Server 2016.

Running a batch file or powershell task just results in a failure.

Tasks.json:

{
    "label": "Sync only",
    "type": "shell",
    "command": "C:/Users/dev/gitToProdSync.bat",
    "problemMatcher": []
},
{
    "label": "Sync Task ps1",
    "command": "powershell",
    "args": [
        "C:/Transfer/git/.vscode/runGitSyncTask.ps1"
    ],
    "type": "shell",
    "problemMatcher": []
}
> Executing task: powershell C:/Transfer/git/.vscode/runGitSyncTask.ps1 <

The terminal process failed to launch: A native exception occurred during launch (Unable to start terminal process: CreateProcess failed).

Terminal will be reused by tasks, press any key to close it.
Read more comments on GitHub >

github_iconTop Results From Across the Web

How to fix VS Code error with Remote-SSH: "the terminal ...
Immediately after connecting, an error pops up saying the terminal process failed to launch: A native exception occurred during launch (forkpty( ...
Read more >
Troubleshoot Terminal launch failures - Visual Studio Code
Try searching in your shell's issue repository. For example, if you are having trouble with WSL, you might find a workaround searching for...
Read more >
Working Remotely with Visual Studio Code and SSH
Type logout and press enter to close your connection to the campus Linux computers and return to your own computer's terminal prompt. Linux¶....
Read more >
What Do I Do If Error Message "The VS Code Server failed to ...
Check whether the VS Code version is 1.65.0 or later. If so, check the Remote-SSH version. · Open the command panel (Ctrl+Shift+P for...
Read more >
Troubleshooting Windows Subsystem for Linux | Microsoft Learn
On Windows 11 open Settings -> System -> Storage -> Advanced storage ... Trying to connect your SSH server is failed with the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found