PowerShell / PowerShellEditorServices

A common platform for PowerShell development support in any editor or application!
MIT License
622 stars 213 forks source link

Loading the PowerShell extension is taking longer than expected #2009

Closed FritzHerbers closed 1 year ago

FritzHerbers commented 1 year ago

Prerequisites

Steps to reproduce

At vscode startup the following error is shown:

The terminal process "C:\Program Files\PowerShell\7\pwsh.exe '-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', 'Import-Module 'c:\Users\user001\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2023.2.1' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\user001\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules' -EnableConsoleRepl -StartupBanner "PowerShell Extension v2023.2.1 Copyright (c) Microsoft Corporation. https://aka.ms/vscode-powershell Type 'help' to get help. " -LogLevel 'Normal' -LogPath 'c:\Users\user001\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\1679587895-8999f298-23d5-47a3-be72-d621c824a8881679587860646\EditorServices.log' -SessionDetailsPath 'c:\Users\user001\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershe...
3/23/2023 5:11:35 PM [NORMAL] - Visual Studio Code v1.75.1 64-bit

3/23/2023 5:11:35 PM [NORMAL] - Creating log directory at: 'file:///c%3A/Users/user001/AppData/Roaming/Code/User/globalStorage/ms-vscode.powershell/logs/1679587895-8999f298-23d5-47a3-be72-d621c824a8881679587860646'

3/23/2023 5:11:35 PM [NORMAL] - PowerShell Extension v2023.2.1
3/23/2023 5:11:35 PM [NORMAL] - Operating System: Windows 64-bit
3/23/2023 5:11:36 PM [NORMAL] - Language server starting --
3/23/2023 5:11:36 PM [NORMAL] -     PowerShell executable: C:\Program Files\PowerShell\7\pwsh.exe
3/23/2023 5:11:36 PM [NORMAL] -     PowerShell args: -NoProfile -ExecutionPolicy Bypass -Command Import-Module 'c:\Users\user001\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2023.2.1' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\user001\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules' -EnableConsoleRepl -StartupBanner "PowerShell Extension v2023.2.1
Copyright (c) Microsoft Corporation.

https://aka.ms/vscode-powershell
Type 'help' to get help.
" -LogLevel 'Normal' -LogPath 'c:\Users\user001\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\1679587895-8999f298-23d5-47a3-be72-d621c824a8881679587860646\EditorServices.log' -SessionDetailsPath 'c:\Users\user001\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-9348-639894.json' -FeatureFlags @() 

3/23/2023 5:11:36 PM [NORMAL] -     PowerShell Editor Services args: Import-Module 'c:\Users\user001\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2023.2.1' -AdditionalModules @('PowerShellEditorServices.VSCode') -BundledModulesPath 'c:\Users\user001\.vscode\extensions\ms-vscode.powershell-2023.2.1\modules' -EnableConsoleRepl -StartupBanner "PowerShell Extension v2023.2.1
Copyright (c) Microsoft Corporation.

https://aka.ms/vscode-powershell
Type 'help' to get help.
" -LogLevel 'Normal' -LogPath 'c:\Users\user001\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\1679587895-8999f298-23d5-47a3-be72-d621c824a8881679587860646\EditorServices.log' -SessionDetailsPath 'c:\Users\user001\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-9348-639894.json' -FeatureFlags @() 
3/23/2023 5:11:36 PM [NORMAL] - pwsh.exe started.
3/23/2023 5:11:36 PM [NORMAL] - Waiting for session file...
3/23/2023 5:12:06 PM [WARNING] - Loading the PowerShell extension is taking longer than expected. If you're using privilege enforcement software, this can affect start up performance.
3/23/2023 5:15:36 PM [NORMAL] - Timed out waiting for session file to appear!
3/23/2023 5:15:36 PM [ERROR] - PowerShell process failed to start: 
3/23/2023 5:15:36 PM [ERROR] - Timed out waiting for session file to appear!
3/23/2023 5:15:36 PM [ERROR] - Unknown session status 'undefined' with reason 'undefined

As it might be caused by "Installing the PowerShell Extension on Restricted Systems": with "pwsh.exe"

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

Import-Module: Could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

with "powershell.exe" the above import-module runs without problem.

Our own scripts work, not sure if they use System.Runtime, but I think this is minimal needed to run.

I need PowerShell 7, what is missing to load the assembly System.Runtime for the PowerShellEditorServices.psd1 script ?

dotnet --list-runtimes Microsoft.AspNetCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.AspNetCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App] Microsoft.NETCore.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.2 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.NETCore.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App] Microsoft.WindowsDesktop.App 6.0.14 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App] Microsoft.WindowsDesktop.App 7.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Expected behavior

No Error

Actual behavior

Error as described above

Error details

No response

Environment data

Name                           Value
----                           -----
PSVersion                      7.1.5
PSEdition                      Core
GitCommitId                    7.1.5
OS                             Microsoft Windows 10.0.17763
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Version

v2023.2.1

Visuals

No response

FritzHerbers commented 1 year ago

updated to 7.3.3