vscode-powershell icon indicating copy to clipboard operation
vscode-powershell copied to clipboard

Language server startup failed

Open QuyenLy73 opened this issue 6 years ago • 66 comments

Issue Description

PS session fails to start with these errors. I have taken the cert from Start-EditorServices.ps1 and imported into my local machine's Trusted Publisher's store. I confirmed it's there with an expiration date of 5/2/2020. I have also executed this command but nothing happens.

Import-Module $HOME.vscode\extensions\ms-vscode.powershell*\modules\PowerShellEditorServices\PowerShellEditorServices.psd1

1/14/2020 2:47:41 PM [NORMAL] - Language server startup failed. 1/14/2020 2:47:41 PM [ERROR] - The language service could not be started: 1/14/2020 2:47:41 PM [ERROR] - Timed out waiting for session file to appear.

Attached Logs

Follow the instructions in the README about capturing and sending logs.

Environment Information

Visual Studio Code

Name Version
Operating System Windows_NT x64 10.0.16299
VSCode 1.41.1
PowerShell Extension Version 2019.12.0

PowerShell Information

Name Value
PSVersion 5.1.16299.1146
PSEdition Desktop
PSCompatibleVersions 1.0 2.0 3.0 4.0 5.0 5.1.16299.1146
BuildVersion 10.0.16299.1146
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Visual Studio Code Extensions

Visual Studio Code Extensions(Click to Expand)
Extension Author Version
All-Autocomplete Atishay-Jain 0.0.23
bracket-pair-colorizer-2 CoenraadS 0.0.29
powershell ms-vscode 2019.12.0
python ms-python 2020.1.58038
todo-tree Gruntfuggly 0.0.162

QuyenLy73 avatar Jan 14 '20 21:01 QuyenLy73

1/14/2020 2:47:41 PM [NORMAL] - Language server startup failed. 1/14/2020 2:47:41 PM [ERROR] - The language service could not be started: 1/14/2020 2:47:41 PM [ERROR] - Timed out waiting for session file to appear.

These logs just indicate that the client waited for the server to start and that it didn't. When you try to start the PowerShell extension, does anything flash in the terminal? Unfortunately, because of the way VSCode works, capturing the screen at that moment (like with a video/gif recorder) might be the only way to get any error message there.

I have also executed this command but nothing happens.

You might also have some luck trying to execute the following from cmd:

powershell.exe -NoProfile -NoLogo -ExecutionPolicy Bypass -Command "$PSES_BUNDLE_PATH/PowerShellEditorServices/Start-EditorServices.ps1 -BundledModulesPath $PSES_BUNDLE_PATH -LogPath $SESSION_TEMP_PATH/logs.log -SessionDetailsPath $SESSION_TEMP_PATH/session.json -FeatureFlags @() -AdditionalModules @() -HostName 'My Client' -HostProfileId 'myclient' -HostVersion 1.0.0 -LogLevel Diagnostic"

With the following set inline:

  • $PSES_BUNDLE_PATH: ~\.vscode\extensions\ms-vscode.powershell-2019.12.0\modules
  • $SESSION_TEMP_PATH: An empty temp directory

If that works, it should print a bunch of information and then block at the point where it waits for a client to connect (you should then kill the process, since there won't be a client to connect). If it doesn't work (which is what I'm hoping, since we need to reproduce this error in an environment where we control the terminal process), then you should see the error in the CMD console.

rjmholt avatar Jan 14 '20 21:01 rjmholt

The cursor just blinks like it's waiting for something?

QuyenLy73 avatar Jan 15 '20 16:01 QuyenLy73

The cursor just blinks like it's waiting for something?

Is this in the Integrated Console after startup? It might be worth trying pressing Enter or entering some input there.

Also see if you're able to run the other command listed above.

rjmholt avatar Jan 15 '20 16:01 rjmholt

Actually looks like I didn't wait long enough. There are now 3 files in my temp directory. logs.ext, Start-EditorServices-logs.txt, and session.json. In the Integrated Console in VSCode, the last status is

#-- Waiting for EditorServicesHost to complete execution ---------------------

QuyenLy73 avatar Jan 15 '20 17:01 QuyenLy73

In the Integrated Console in VSCode, the last status is

#-- Waiting for EditorServicesHost to complete execution ---------------------

That means it should be ready to go. Do you get a prompt?

rjmholt avatar Jan 15 '20 17:01 rjmholt

The PS Integrated Console does not let me type anything in there. It tries to start up with a Starting Powershell message and eventually throws an initialization error which is the Language server startup error that I posted here. I ran the command in a different Powershell terminal session within VS code. I assume this is just the PS on the OS. In this window, I get the Waiting for EditorServicesHost message but I can't type anything after that message. I'm still not able to run any of my PS scripts from within VSCode because it says Cannot Debug or Run Powershell Script until the Powershell session has started.

QuyenLy73 avatar Jan 15 '20 18:01 QuyenLy73

There are now 3 files in my temp directory. logs.ext, Start-EditorServices-logs.txt, and session.json

Can you post those files here? (Or send them through by email: see the troubleshooting doc)

I assume this is just the PS on the OS

That's indeed what that is.


From what you've described so far, it sounds like the PowerShell process that runs the server is correctly getting to the point where it's waiting on a client connection but for some reason the client never connects properly. If the logs don't reveal anything, it might be worth trying the preview extension instead, especially since that will be stable within the month.

rjmholt avatar Jan 15 '20 18:01 rjmholt

Files uploaded. Where do I get the preview extension? I've tried rolling back to an older version but still same issue.

QuyenLy73 avatar Jan 15 '20 18:01 QuyenLy73

Where do I get the preview extension?

It's in the VSCode marketplace as powershell-preview. You'll need to uninstall the powershell extension for it to work properly.

rjmholt avatar Jan 15 '20 18:01 rjmholt

Unfortunately same issue with the preview version. Might try uninstalling VSCode and re-install.

QuyenLy73 avatar Jan 15 '20 18:01 QuyenLy73

Re-installing VSCode didn't help.

QuyenLy73 avatar Jan 15 '20 19:01 QuyenLy73

Can you post of a GIF of the whole VSCode window as the extension starts up?

rjmholt avatar Jan 15 '20 19:01 rjmholt

The other thing I noticed is that the Windows version you're using (RS3) may be end-of-life. Sometimes these kinds of hang issues that we can't reproduce are caused by changes in Windows fixed by patches.

rjmholt avatar Jan 15 '20 19:01 rjmholt

The terminal is blank with a Starting Powershell... message at the bottom right. Are you wanting a screenshot of the Output window? Unfortunately I can't control the Windows version. This machine is my work laptop. The Powershell extension is a Microsoft product correct? My next route will have to be to submit a ticket to MS if I can't figure this out myself soon.

QuyenLy73 avatar Jan 15 '20 19:01 QuyenLy73

Are you wanting a screenshot of the Output window?

A GIF/video of the startup would be ideal, something that shows the extension load when the first PowerShell file is opened and then the Integrated Console appear and start, right until the last message that you posted earlier is logged. It might not show any new information, but sometimes there's a clue in the greater VSCode window.

Unfortunately I can't control the Windows version. This machine is my work laptop.

In that case I believe RS3 is good until April. But in an enterprise context, sometimes anti-virus or group policy prevent startup. It's not entirely clear how we'd show that, but some users have found they can reproduce the same issue on various work devices with different Windows and PowerShell versions, while also having no problem starting the extension on personal devices. If you find that's the case, we'd be grateful for any data you can provide since this is something that crops up from time to time but is very hard to reproduce.

The Powershell extension is a Microsoft product correct?

This is indeed software developed, maintained and made available by Microsoft. I am a Microsoft engineer.

rjmholt avatar Jan 15 '20 19:01 rjmholt

This was working fine before the holiday break. I upgraded to the latest extension recently so not sure what triggered the issue. Could very well be Windows hotfix, GPO, etc... I just need to figure out what exactly. I can try and record VSCode but it pretty much shows me a blank terminal window while it's starting up. I don't see anything else.

QuyenLy73 avatar Jan 15 '20 19:01 QuyenLy73

Any advice on what specific group policy to look for? Isn't this just trying to run a PS script behind the scenes? ie Start-EditorServices.ps1?

QuyenLy73 avatar Jan 15 '20 19:01 QuyenLy73

This was working fine before the holiday break. I upgraded to the latest extension recently so not sure what triggered the issue.

Yeah we've heard similar in other cases. Often it seems the extension hasn't changed, or even VSCode (since they're totally separate). But one day it just stops working. Possibly a Windows patch, perhaps more likely a policy rollout.

Isn't this just trying to run a PS script behind the scenes? ie Start-EditorServices.ps1?

Yeah, VSCode starts a child process like powershell.exe -noprofile -nologo -command 'C:\path\to\Start-EditorServices.ps1 ... <parameters for connecting, like named pipe name>'

I can try and record VSCode but it pretty much shows me a blank terminal window while it's starting up. I don't see anything else.

In the absence of other information it could be helpful. It likely won't shed new light, but sometimes there's a clue.

Any advice on what specific group policy to look for?

Unfortunately I don't know very much about GPO or how exactly it could interact with the extension, just that some other users have reported it doing so. I'll try and do some research on it. In the meantime, this issue is marked for triage so I'll discuss it with some other team members tomorrow.

rjmholt avatar Jan 15 '20 20:01 rjmholt

At the point the extension seems to be stuck, the server has created an ACL'd named pipe and the client should be connecting over that named pipe

rjmholt avatar Jan 15 '20 20:01 rjmholt