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 490 forks source link

Never ending loop to trying to activate extention when trying to run PS script #5045

Closed jason-collab closed 1 month ago

jason-collab commented 1 month ago

Type: Bug

Even with simple scripts, the PowerShell extension does't appear to ever fullly activate...just loops. VSC and all extensions are up to date. It even occurs for a simple script like as follows:

Connect-MicrosoftTeams Get-CsOnlineUser -Identity

Extension version: 2024.2.2 VS Code version: Code 1.93.1 (38c31bc77e0dd6ae88a4e9cc93428cc27a56ba40, 2024-09-11T17:20:05.685Z) OS version: Windows_NT x64 10.0.19045 Modes:

System Info |Item|Value| |---|---| |CPUs|13th Gen Intel(R) Core(TM) i7-1365U (12 x 2688)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: enabled_on
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_graphite: disabled_off
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: enabled
webnn: disabled_off| |Load (avg)|undefined| |Memory (System)|15.64GB (4.00GB free)| |Process Argv|--crash-reporter-id 0f61217d-3470-41e0-8842-8e86025f25a9| |Screen Reader|no| |VM|0%|
A/B Experiments ``` vsliv368cf:30146710 vspor879:30202332 vspor708:30202333 vspor363:30204092 vscod805:30301674 binariesv615:30325510 vsaa593:30376534 py29gd2263:31024239 vscaat:30438848 c4g48928:30535728 azure-dev_surveyone:30548225 962ge761:30959799 pythongtdpath:30769146 welcomedialogc:30910334 pythonnoceb:30805159 asynctok:30898717 pythonmypyd1:30879173 h48ei257:31000450 pythontbext0:30879054 accentitlementst:30995554 dsvsc016:30899300 dsvsc017:30899301 dsvsc018:30899302 cppperfnew:31000557 dsvsc020:30976470 pythonait:31006305 dsvsc021:30996838 01bff139:31013167 a69g1124:31058053 dvdeprecation:31068756 dwnewjupytercf:31046870 impr_priority:31102340 refactort:31108082 pythonrstrctxt:31112756 flightc:31134773 wkspc-onlycs-t:31132770 wkspc-ranged-t:31125599 pme_test_c:31118331 ei213698:31121563 iacca2:31138163 ```
jason-collab commented 1 month ago

image

JustinGrote commented 1 month ago

Thanks for the submission! Could you submit us some logs so maybe we can see something? Have you also tried disabling your profile in the settings?

jason-collab commented 1 month ago

I apologize, I mainly use VSC for running PowerShell...so I'm not very familar with all the configuration settings for it. I have attached a few of the logs...hopefully that can help. Thanks! PowerShellEditorServices-25812.log vscode-powershell.log StartEditorServices-25812.log

Just to clarify, I have no problem copying the body of a script from the Editor Panel and pasting into the Terminal Panel tab on the bottom...it runs fine that way. It just seems like the extension service is having trouble initializing and connecting to VSC so it won't run that script if I choose if from the Side Bar/Explorer and press the run button.

SydneyhSmith commented 1 month ago

@jason-collab do you have a powershell profile? Can you clarify how did you start the extension? Do you have trouble with any other extensions? Thanks!

jason-collab commented 1 month ago

Nope...I don't have a PowerShell profile. I just run the default. Here is my VSC settings.json: image

I usually just need to launch VSC, click on a script in the side bar explorer, and press the run button. For about the past month or so, the PowerShell extension just won't fully activate. It just keeps initializing. So, I have been resorting to copy/paste into the Terminal panel of VSC at this point. I haven't had any trouble with other extensions. I even tried the Start Extension Bisect suggestion in this article and it only finds a problem with the PowerShell extension.

JustinGrote commented 1 month ago

@jason-collab I'm not seeing anything in the logs, looks pretty normal, not sure what it would be hanging on. Have you tried starting a new vscode fresh profile with no settings or extensions specified, only install the PS extension, and see if it reoccurs there (don't log in to sync settings either into that profile)

https://code.visualstudio.com/docs/editor/profiles

jason-collab commented 1 month ago

Same issue. I created a new empty provide, added only the PowerShell extension, then tried to run a script...but same issue. image

JustinGrote commented 1 month ago

Does the same occur on another computer? I unfortunately cannot reproduce this in any combination and without a solid reproduction we have no way of knowing how to fix it.

jason-collab commented 1 month ago

Well, I know that our organization implemented BeyondTrust about 6 months ago...but I don't know anything about it. Any idea if that could be causing the issue? I wouldn't think so since I can still run PowerShell from the VSC terminal. But could that be hanging up the extension perhaps?

JustinGrote commented 1 month ago

Certainly these kind of intermittent or "immediate death" issues can be caused by antivirus and other products seeing pwsh.exe as a threat and halting the execution. Would have to check the logs of the relevant products to be sure.

jason-collab commented 1 month ago

Well, I found this https://github.com/PowerShell/vscode-powershell/issues/3077. Although it is not the exact same issue, I tried to run VSC as administrator and it finally worked for me now. I never had to do that before. So, I'm guessing BeyondTrust is causing some kind of problem there. However, for the sake of time, I'm not going to go down the rabbit hole of trying to find out why. It looks like that could be pretty time consuming. I'll just run as administrator from now on. Thanks for help @JustinGrote 👍 .