Skip to content
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

PowerShell extension stuck at "Starting PowerShell.." #1626

Closed
compwiz32 opened this issue Dec 3, 2018 · 51 comments
Closed

PowerShell extension stuck at "Starting PowerShell.." #1626

compwiz32 opened this issue Dec 3, 2018 · 51 comments
Assignees
Labels
Area-Startup Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.

Comments

@compwiz32
Copy link

compwiz32 commented Dec 3, 2018

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

AlanWalk.markdown-toc@1.5.6
CoenraadS.bracket-pair-colorizer-2@0.0.25
formulahendry.code-runner@0.9.5
gerane.Theme-Blackboard@0.0.2
in4margaret.compareit@0.0.2
jprestidge.theme-material-theme@1.0.1
mdickin.markdown-shortcuts@0.9.0
ms-vscode.PowerShell@1.9.0
ms-vscode.wordcount@0.1.0
PKief.material-icon-theme@3.6.1
shd101wyy.markdown-preview-enhanced@0.3.11
streetsidesoftware.code-spell-checker@1.6.10
yzane.markdown-pdf@1.2.0
yzhang.markdown-all-in-one@1.7.0

@rkeithhill
Copy link
Contributor

rkeithhill commented Dec 3, 2018

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.

@compwiz32
Copy link
Author

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

@rkeithhill
Copy link
Contributor

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

@compwiz32
Copy link
Author

compwiz32 commented Dec 3, 2018

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
Copy link
Author

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

@SydneyhSmith
Copy link
Collaborator

@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

@compwiz32
Copy link
Author

@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?

@rjmholt
Copy link
Contributor

rjmholt commented Dec 5, 2018

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
Copy link
Contributor

rjmholt commented Dec 5, 2018

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.

@SeeminglyScience
Copy link
Collaborator

@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.

@TheoNordstrom
Copy link

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
Copy link

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.

@darkocobe
Copy link

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?

@TylerLeonhardt
Copy link
Member

Can everyone here try this workaround:
#1633 (comment)

@rjmholt
Copy link
Contributor

rjmholt commented Dec 6, 2018

See #1633 (comment) for the DLL to download

@compwiz32
Copy link
Author

@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
Copy link
Author

@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

@rjmholt
Copy link
Contributor

rjmholt commented Dec 6, 2018

@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.

@compwiz32
Copy link
Author

@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.

@rjmholt
Copy link
Contributor

rjmholt commented Dec 6, 2018

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 vscode-powershell@microsoft.com if you're not sure.

@compwiz32
Copy link
Author

compwiz32 commented Dec 6, 2018

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"

@rjmholt
Copy link
Contributor

rjmholt commented Dec 6, 2018

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

@darkocobe
Copy link

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.

@pdahlgren
Copy link

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.

@compwiz32
Copy link
Author

compwiz32 commented Mar 22, 2019

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
Copy link
Author

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?

@zachmerrill
Copy link

zachmerrill commented Mar 22, 2019

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
Copy link

@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 :)

@compwiz32
Copy link
Author

@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?

@zachmerrill
Copy link

@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 :)

@nashiooka
Copy link

nashiooka commented Dec 8, 2020

FYI previous advice from @kristianBirkThim worked for me too. I believe the problem started after upgrading to 1.51.1 with extension version 2020.6.0.

@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Dec 8, 2020
@M-Pixel
Copy link

M-Pixel commented Feb 6, 2021

I was able to resolve this issue by upgrading from PowerShell Core 6 to 7, but it was a lucky guess. The error reporting and resiliency still need a lot of work.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Feb 6, 2021
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Feb 9, 2021
@nashiooka
Copy link

nashiooka commented Feb 17, 2021

Sorry but I'm still having this issue. At first it seemed like it went away after formally installing PowerShell 7.1, then switching back to 5.1, but I can't seem to completely shake it. Seems like it particularly occurs when I'm using a second or third window. However it's not consistent. I just updated to 1.53 and that seemed to fix it for the 2 windows I had, but I just opened a 3rd and it's back. Sometimes I'm able to get out of the "Starting PowerShell..." state by switching the version in the runtime config, but it still a pain.

@ghost ghost added the Needs: Maintainer Attention Maintainer attention needed! label Feb 17, 2021
@SydneyhSmith SydneyhSmith removed the Needs: Maintainer Attention Maintainer attention needed! label Feb 23, 2021
@Curtisbrinkman
Copy link

I had this issue on my Mac and updating PowerShell using these instructions fixed it: https://docs.microsoft.com/en-us/powershell/scripting/install/installing-powershell-on-macos?view=powershell-7.2

I ran: brew install --cask powershell

Reloaded visual studio and it started working again.

@mathewgries
Copy link

Doesn't look like there's been much action on this one lately. This is my second time running into this issue and for me it is related to the execution policy regarding localMachine.

Here is the MS doc regarding the policy:
https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.2

Here is what I run in a powershell command prompt to fix the issue:
Check the policy setting:
Get-ExecutionPolicy -List

Most likely the setting here will be:
LocalMachine Restricted

To set it to RemoteSigned, and fixing this issue:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope LocalMachine

@schnajberkp
Copy link

Same thing happened to me, I tried almost everything you said.
But to fix the issue for me, it was actually needed to not install Powershell through the .msi but through CMD.
winget install --id Microsoft.Powershell --source winget
winget install --id Microsoft.Powershell.Preview --source winget
Now im able to run PS1 scripts in VS Code

@yudindm
Copy link

yudindm commented Dec 22, 2022

I run into this issue after I updated PowerShell from 7.1 to 7.3.

I have configured VS Code to use Windows PowerShell because it's my default target
"powershell.powerShellDefaultVersion": "Windows PowerShell (x64)"

But sometimes I use PowerShell 7 for some experimental work, so I have PowerShell 7 installed on my machine.

All works correctly when I change powerShellDefaultVersion to "PowerShell (x64)" or uninstall PowerShell 7.

@benblank
Copy link

Changing the execution policy for the local machine worked for me, too. I did note, however, that my non-administrator user account had its own execution policy, which overrode the local machine's. All I had to do to fix that was to unset it (as the non-administrator user).

Set-ExecutionPolicy -ExecutionPolicy Undefined -Scope CurrentUser

@andyleejordan
Copy link
Member

andyleejordan commented Apr 27, 2023

Hey @compwiz32, I know this issue is from 2018. Is it still reproducing for you? I'm going to mark as "needs feedback" so it will auto-close in a week if I don't hear back from you. For other users posting, if you are having problem today, please file a new issue so we can get back to you. Thanks all!

@andyleejordan andyleejordan added the Needs: Author Feedback Please give us the requested feedback! label Apr 27, 2023
@andyleejordan andyleejordan moved this to In Progress in Flying Fox Apr 27, 2023
@andyleejordan andyleejordan self-assigned this Apr 27, 2023
@compwiz32
Copy link
Author

Hi guys! I apologize. I thought I closed this issue a long time ago. I do remember this issue and do remember that future builds fixed my issue. definitely no lingering issues...

@github-project-automation github-project-automation bot moved this from In Progress to Done in Flying Fox Apr 27, 2023
@ghost ghost added Needs: Maintainer Attention Maintainer attention needed! and removed Needs: Author Feedback Please give us the requested feedback! labels Apr 27, 2023
@ghost ghost reopened this Apr 27, 2023
@andyleejordan
Copy link
Member

Yay, glad to hear that! Thanks for the follow-up.

@andyleejordan andyleejordan added Resolution-Fixed Will close automatically. and removed Needs: Maintainer Attention Maintainer attention needed! labels Apr 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Startup Issue-Bug A bug to squash. Resolution-Fixed Will close automatically.
Projects
Status: Done
Development

No branches or pull requests