PowerShell / vscode-powershell

Provides PowerShell language and debugging support for Visual Studio Code
https://marketplace.visualstudio.com/items/ms-vscode.PowerShell
MIT License
1.71k stars 488 forks source link

Extension stuck on loading #5057

Open opmdsm opened 1 month ago

opmdsm commented 1 month ago

Prerequisites

Summary

Hi,

This is the second time when I face this situation. Scenario: Fresh install of Visual Studio Code (VSC), then install PowerShell extension from Microsoft. Upon requesting to trust publisher, I press A (always trust) in the terminal window and then nothing happens. I leave it for 1-2h without nothing to happen and then force to stop it. Restarting VSC and Windows PowerShell (x64) is never loading, the bottom-right icon is spinning forever. Switching to Windows PowerShell (x86) is working. The first time when this happened was 2-3 years ago and I remember I've spent also lot of time trying to figure out how to fix this. I discovered the fix by mistake: Found a post about OneDrive somehow corrupting some PowerShell (psm/psd) files from Documents folder or someting. Running chkdsk from command propmt fixed the issue. But now this doesn't seems to have any effect. Any ideas what can I do?

Thanks, Marius.

PowerShell Version

Name                           Value                                                                                                                   
----                           -----                                                                                                                   
PSVersion                      5.1.22621.4249                                                                                                          
PSEdition                      Desktop                                                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                 
BuildVersion                   10.0.22621.4249                                                                                                         
CLRVersion                     4.0.30319.42000                                                                                                         
WSManStackVersion              3.0                                                                                                                     
PSRemotingProtocolVersion      2.3                                                                                                                     
SerializationVersion           1.1.0.1                                                                                                                 

Name             : Windows PowerShell ISE Host
Version          : 5.1.22621.4249
InstanceId       : 64347789-db94-40f5-9118-5d2a0c2cc76b
UI               : System.Management.Automation.Internal.Host.InternalHostUserInterface
CurrentCulture   : en-US
CurrentUICulture : en-US
PrivateData      : Microsoft.PowerShell.Host.ISE.ISEOptions
DebuggerEnabled  : True
IsRunspacePushed : False
Runspace         : System.Management.Automation.Runspaces.LocalRunspace

Visual Studio Code Version

1.94.0

Extension Version

v2024.2.2

Steps to Reproduce

See Summary section

Visuals

No response

Logs

No response

opmdsm commented 1 month ago

Screenshot 2024-10-04 125638

This is how terminal looks like

opmdsm commented 1 month ago

Screenshot 2024-10-04 134407

tonysathre commented 1 month ago

Been having the same issue for the past week or so. Seems to only happen when switching the session to PS 5.1. My workaround is to switch the shell by running powershell in my pwsh session, instead of using the PowerShell: Show Session Menu -> Switch to: command.

JustinGrote commented 1 month ago

Thanks for the submission! The most common reason we've been seeing this lately is an antivirus program blocking or halting the execution of the PowerShell extension. Do you have any antivirus programs installed?

Otherwise there's not much we can do without a reproducible method, I just tried it in a fresh Windows Server and Windows 11 VM and both worked fine, can you install PowerShell 7? PowerShell 5.1 is as-is support, PowerShell 7 will work better even if you are only authoring 5.1 scripts.

JustinGrote commented 1 month ago

So I've actually seen multiple reports on this so there might be something, but on my Win11 machine and in a clean environment, WinPS 32, WinPS64, and PS7.4 all load just fine with 1.94 vscode.

@andyleejordan FYI in case you have an idea.

JustinGrote commented 1 month ago

Report from jcotton42 on discord image

andyleejordan commented 4 weeks ago

I wonder, is it related to the shell integration path moving? They released that changer sooner than I expected so we're temporarily broken. Working on getting a release out ASAP.

opmdsm commented 3 weeks ago

Been having the same issue for the past week or so. Seems to only happen when switching the session to PS 5.1. My workaround is to switch the shell by running powershell in my pwsh session, instead of using the PowerShell: Show Session Menu -> Switch to: command.

I will try it, thanks.

opmdsm commented 3 weeks ago

Thanks for the submission! The most common reason we've been seeing this lately is an antivirus program blocking or halting the execution of the PowerShell extension. Do you have any antivirus programs installed?

Otherwise there's not much we can do without a reproducible method, I just tried it in a fresh Windows Server and Windows 11 VM and both worked fine, can you install PowerShell 7? PowerShell 5.1 is as-is support, PowerShell 7 will work better even if you are only authoring 5.1 scripts.

I have the built in MS Defender, that's all. I tried on other machines and it's working, it's something particular on my machine.

opmdsm commented 3 weeks ago

Hi,

Anyone knows how can I trigger again that popup/dialog with adding a trust publisher when installing an extension? I mean the very first time when you install a extension from a publisher and you are asked if you trust that publisher. I'm trying to untrust and trust again that publisher maybe it works. For that I uninstalled Visual Studio Code and then removed .vscode folder from user's folder and also Code folder from C:\Users\\AppData\Roaming. No luck, only initial setup was triggered (choosing theme, etc).

Thanks, Marius.

opmdsm commented 2 weeks ago

This is the trust publisher question which never ends when I press A: "Do you want to run software from this untrusted publisher? File C:\Users\MyUserName.vscode\extensions\ms-vscode.powershell-2022.11.0\modules\PowerShellEditorServices\Commands\PowerShellEditorServices.Commands.types. ps1xml is published by CN=Microsoft Corporation, O=Microsoft Corporation, L=Redmond, S=Washington, C=US and is not trusted on your system. Only run scripts from trusted publishers. [V] Never run [D] Do not run [R] Run once [A] Always run [?] Help (default is "D"):"

alberto-bottacin commented 6 days ago

Hi, I solved the same issue by run this powershell command: Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

this will allow to run powershell scripts with the curret user (both on Powershell ISE and Visual Studio Code)