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

PowerShell extension stuck at "Starting PowerShell.."

Open compwiz32 opened this issue 6 years ago • 44 comments

Issue Description

I am experiencing a problem with PowerShell extension. I have checked issue #752 and I am confident that the fixes in that bug report are applied.

The PowerShell extension hangs when the second terminal (PowerShell Integrated Console) starts. It never times out and it never crashes, it just stays stuck at "Starting PowerShell..."

I have noticed the issue on another PC in my org so I am wondering if it is an issue with our image build with our laptops but... I can't get anything to show in the logs, so I am stuck trying to figure out what is hanging the extension up.

I enabled diagnostic mode but it doesn't seem to have caught any additional info.

Attached Logs

Start-EditorServices-EditorServices.log vscode-powershell.log EditorServices.log

Environment Information

Visual Studio Code

1.29.1 bc24f98b5f70467bc689abf41cc5550ca637088e x64

Name Version
Operating System Windows 10 1709
VSCode 1.29.1
PowerShell Extension Version 1.9.0

PowerShell Information

PS C:\Scripts\Git-Repo\PS-ADHeath> $psversiontable

Name Value


PSVersion 5.1.16299.666 PSEdition Desktop PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...} BuildVersion 10.0.16299.666 CLRVersion 4.0.30319.42000 WSManStackVersion 3.0 PSRemotingProtocolVersion 2.3 SerializationVersion 1.1.0.1

Visual Studio Code Extensions

[email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected] [email protected]

compwiz32 avatar Dec 03 '18 15:12 compwiz32

Can you change the "powershell.developer.editorServicesLogLevel" setting to Diagnostic in your user settings and repro this again and attach that EditorServices.log file? That should provide a lot more detail during startup.

rkeithhill avatar Dec 03 '18 16:12 rkeithhill

Hi @rkeithhill

I had enabled that prior to the first upload. I just went back through the logs and can't find anything that jumps out. I am going to attach two zips: the last two launches of VSCODE in case I am missing something really obvious.

{
    "editor.minimap.enabled": false,
    "window.zoomLevel": 0,
    "workbench.colorTheme": "Blackboard",
    "terminal.integrated.shell.windows": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
    "powershell.powerShellExePath": "C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe",
    "files.associations": {
        "*.ps1": "powershell"
    },
    "powershell.enableProfileLoading": true,
    "editor.renderWhitespace": "none",
    "editor.renderControlCharacters": true,
    "files.trimTrailingWhitespace": true,
    "breadcrumbs.enabled": false,
    "powershell.integratedConsole.showOnStartup": false,
    "powershell.developer.editorServicesLogLevel": "Diagnostic"

}

1543850094-c1b1601a-e9ac-4afd-afe2-46fa771a60f31543850083161.zip 1543854564-4b234fa9-b485-4a84-af31-946de20c890b1543854525112.zip

compwiz32 avatar Dec 03 '18 16:12 compwiz32

Doh! Not much of anything to go on there. Can you check the EventViewer on Windows. See if there is any error related to PowerShell in the Application log around the time it crashes/terminates. If you see nothing there, check the Windows PowerShell log here:

image

rkeithhill avatar Dec 03 '18 16:12 rkeithhill

I'll check now... the problem is that I don't think the extension ever crashes. it just sits at starting PowerShell, the only real issue I have noticed is not being about to debug.

Looking at Event Viewer now...

image

compwiz32 avatar Dec 03 '18 16:12 compwiz32

nothing in the logs other informational stuff. :( Frustrating how little I have to go on here.

compwiz32 avatar Dec 03 '18 16:12 compwiz32

@compwiz32 Is the device you are using, restricted or locked down in anyway, for example with Group Policy? We are also releasing a new version of the extension this week, lets see if that helps this problem at all

SydneyhSmith avatar Dec 04 '18 22:12 SydneyhSmith

@SydneyhSmith My hunch going into opening this thread was that, yes, my issue is environment specific. Yes, I have a decent amount of GPO's and defense industry lock-downs (but not too bad). I am cool waiting for the next version.

However, I am frustrated that I can't seem to generate an error that would point me in the direction of where the error may lie. Other than switching from diagnostic to verbose logging, anything else I could try to possibly highlight where my issue may be?

compwiz32 avatar Dec 05 '18 02:12 compwiz32

If you're able to edit the Start-EditorServices.ps1 script (should be at $HOME\.vscode\extensions\ms-vscode.powershell-1.9.0\modules\PowerShellEditorServices\Start-EditorServices.ps1) you might be able to put $ErrorActionPreference = 'Stop' at the top. That script imports the PowerShellEditorServices module, uses Add-Type to bring in the required DLLs for the platform, and calls the entry API to start EditorServices within the PowerShell process it starts up. You can find all those bits here.

If you can see any other possibilities for logging in Start-EditorServices.ps1, let us know as well.

I've seen one or two of these mysterious failures now, where I'm really not sure what's causing the issue. The fundamental problem is that we have a client/server architecture, so when the server doesn't reply, the client doesn't know what's failed.

rjmholt avatar Dec 05 '18 03:12 rjmholt

Another thought I've had: it may end up that the script is not "failing" just blocked forever on something. If so, it might be possible to put a Wait-Debugger in the top of the script and then step through one line at a time in the Integrated Console with s.

rjmholt avatar Dec 05 '18 03:12 rjmholt

@compwiz32

This looks sort of similar to when something is blocking nodepty.exe. Are you able to specify which anti-virus you are using? I know someone reported needing to white list it within McAfee, though that may have been an internal rule set.

SeeminglyScience avatar Dec 05 '18 12:12 SeeminglyScience

I do have same problem with PowerShell Extension in VSCode. At first, the editor would not start because it could not find 'api-ms-win-core-sysinfo-l1-2-0.dll' - I found a workaround - see #1633

If a debug session run until end of script, the debugger will not start on 2nd run. If I break and stop the debug session, then a 2nd debug session works fine. The problem starts this morning after reload of vscode to Version: 1.29.1 (system setup) Commit: bc24f98b5f70467bc689abf41cc5550ca637088e Date: 2018-11-15T19:13:36.375Z Electron: 2.0.12 Chrome: 61.0.3163.100 Node.js: 8.9.3 V8: 6.1.534.41 Architecture: x64

TheoNordstrom avatar Dec 06 '18 09:12 TheoNordstrom

I have tried the Debug open new session as mentioned above. I get the error: 12/6/2018 11:23:33 AM [ERROR] - The language service could not be started: 12/6/2018 11:23:33 AM [ERROR] - Timed out waiting for session file to appear.

  • same error as reported in EditorServices.log in #1633

TheoNordstrom avatar Dec 06 '18 10:12 TheoNordstrom

I have exactly same problem since 1.10 update. Didn't had this problem before. Did you already found any solution/workaround or we need to wait until next release?

darkocobe avatar Dec 06 '18 16:12 darkocobe

Can everyone here try this workaround: https://github.com/PowerShell/vscode-powershell/issues/1633#issuecomment-444814977

TylerLeonhardt avatar Dec 06 '18 17:12 TylerLeonhardt

See https://github.com/PowerShell/vscode-powershell/issues/1633#issuecomment-444955893 for the DLL to download

rjmholt avatar Dec 06 '18 18:12 rjmholt

@compwiz32

This looks sort of similar to when something is blocking nodepty.exe. Are you able to specify which anti-virus you are using? I know someone reported needing to white list it within McAfee, though that may have been an internal rule set.

My A/V: Symantec AV I took a good look through the AV logs and don't see anything pointing to a file block.

FYI - v1.10.0 made no difference for me and I did import the new DLL listed in #1633 as directed by @TylerLeonhardt

I am working through @rjmholt suggestions now re ErrorAction Stop and Wait-Debugger. I'll comment after testing. I also believe that this probably a case of "just blocked forever on something" rather than a bug.

compwiz32 avatar Dec 06 '18 19:12 compwiz32

@rjmholt I found a workaround that has temporarily solved my issue... I went back to the system version of VSCODE and success!!!

So this tells me that we have a permissions issue somewhere. Our laptops have some "unique" lockdowns so I am not sure how to troubleshoot that... Any ideas?

image

compwiz32 avatar Dec 06 '18 21:12 compwiz32

@compwiz32 That's excellent. I'm following up now to see if there are any ways in general to do something like turn one of these hangs into a crash or something similar.

rjmholt avatar Dec 06 '18 22:12 rjmholt

@rjmholt

Maybe I can save you some time. I know of issues we have had in the past due to security requirements that block us from interacting with the "Windows Store". If you can think of any reason why VScode may be waiting for an answer from an online MS service, that may be the issue here.

I say that knowing that there should not be any talk to an online service just to load a language but throwing it out there as a remote possibility. I will put into place whatever you might come up with for a future test.

compwiz32 avatar Dec 06 '18 22:12 compwiz32

So after looking into this, it looks like there are a couple of avenues to explore:

  1. Open an issue on VSCode, since it seems that there is something in their User-build preventing startup from occurring properly. They have had funny network-based hangs in the past.
  2. In Task Manager, look for VSCode and you should be able to find it and its child processes. Create a dump file of powershell.exe or pwsh.exe as well as a dump of VSCode and send it to us (it may have some private information in it depending on your program, so send it to [email protected] if you're not sure.

rjmholt avatar Dec 06 '18 22:12 rjmholt

Can I run the user and system versions side by side? I uninstalled the user version to make sure the system version didn't step on or pick up "old bits of code"

compwiz32 avatar Dec 06 '18 22:12 compwiz32

Looks like side-by-side is possible although you might get warnings about it.

rjmholt avatar Dec 06 '18 22:12 rjmholt

For me nothing helped. I tried all kind of things and I was already running system version. I tried also user version but same issue with 1.10 version. I finally gave up and uninstalled 1.10 and returned back to 1.9 which works perfectly fine. If you have any updates please inform me so I can test.

darkocobe avatar Dec 07 '18 10:12 darkocobe

I had the same problem and noticed that I had a deleted folder in my vscode workspace. After I removed this folder from the workspace everythin was working fine.

pdahlgren avatar Mar 05 '19 11:03 pdahlgren

Hello gents... i am back again... I am still suffering from this issue.... It went away after a system install months ago and then came back a very short while after (like maybe next reboot). I was just dealing with it until I got fed up today. I reinstalled the user version and I am still hung at "Starting PowerShell..." I am attaching the editorservices.log and the vscode-powershell.log files with the hope that maybe they will reveal something i haven't noticed, but there isn't much in there...

vscode-powershell.log EditorServices.log Start-EditorServices-EditorServices.log

compwiz32 avatar Mar 22 '19 18:03 compwiz32

I am wondering if there's a permissions issue where the pipe points to. Is there a way to figure out where a pipe is on my machine?

compwiz32 avatar Mar 22 '19 19:03 compwiz32

Just found this thread, I'm running into the same problem on my work machine. It seems to hang on the line

3/22/2019 3:27:02 PM [NORMAL] - Connecting to language service on pipe \\.\pipe\PSES_untqesdw.qj4...

Also, my PowerShell window pops out (it's not integrated). This was working when I first tried it, but stopped a few hours later. It's a shame because this extension is extremely useful for my PowerShell development.

zachmerrill avatar Mar 22 '19 19:03 zachmerrill

@compwiz32 I was able to solve my problem by installing PowerShell Core (https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-core-on-windows?view=powershell-6) with administrator permissions and then changing the Power Shell Exe Path in vscode to point to it.

It now starts up correctly! Maybe this will work for you as well :)

zachmerrill avatar Mar 26 '19 14:03 zachmerrill

@zachmerrill so are you saying you installed PSCore and then in VSCODE pointed the PS executable path to PSCORE PS Exe ?

Just very interesting but I wonder what changes for your everyday PS experience?

compwiz32 avatar Mar 26 '19 14:03 compwiz32

@compwiz32 Correct. I now have two versions of PowerShell installed (PSCore and the version preinstalled on my system). I only use PSCore for the VSCode extension, so it shouldn't affect my day to day too much.

Here's the things I tried if you're interested...

  1. I modified the pipe location in the extension script Start-EditorServicesHost.ps1 but this didn't have any effect.
  2. I then tried to run Start-EditorServicesHost.ps1 manually in a terminal and got the following error: The specified module 'PowerShellEditorServices' was not loaded because no valid module file was found in any module directory.
  3. After searching, I found this doc online https://docs.microsoft.com/en-us/powershell/scripting/components/vscode/using-vscode?view=powershell-6#installing-the-powershell-extension-on-restricted-systems But this still didn't work for me...
  4. As a final effort I installed PSCore and that worked!

Good luck :)

zachmerrill avatar Mar 26 '19 14:03 zachmerrill