Skip to content

2024.4.0: Unable to start when using Windows PowerShell if older Serilog is already present #5084

Closed
PowerShell/PowerShellEditorServices
#2197

Description

@ajacks88

Prerequisites

  • I have written a descriptive issue title.
  • I have searched all open and closed issues to ensure it has not already been reported.
  • I have read the troubleshooting guide.
  • I am sure this issue is with the extension itself and does not reproduce in a standalone PowerShell instance.
  • I have verified that I am using the latest version of Visual Studio Code and the PowerShell extension.
  • If this is a security issue, I have read the security issue reporting guidance.

Summary

Attempting to launch vscode's powershell extension and get an error. Googling found others with the same issue.

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

Visual Studio Code Version

1.95.1
x64

Extension Version

ms-vscode.powershell@2024.4.0

Steps to Reproduce

Launch vscode, get the following error:

Exception encountered starting EditorServices. Exception logged in C:__w\1\s\src\PowerShellEditorServices.Hosting\Commands\StartEditorServicesCommand.cs on line 239 in EndProcessing:
System.MissingMethodException: Method not found: 'Microsoft.Extensions.Logging.ILoggerFactory Serilog.SerilogLoggerFactoryExtensions.AddSerilog(Microsoft.Extensions.Logging.ILoggerFactory, Serilog.ILogger, Boolean)'.
at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesServerFactory.Create(String logDirectoryPath, Int32 minimumLogLevel, IObservable1 hostLogger) at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesRunner..ctor(HostLogger logger, EditorServicesConfig config, ISessionFileWriter sessionFileWriter, IReadOnlyCollection1 loggersToUnsubscribe)
at Microsoft.PowerShell.EditorServices.Hosting.EditorServicesLoader.LoadAndRunEditorServicesAsync()
at Microsoft.PowerShell.EditorServices.Commands.StartEditorServicesCommand.EndProcessing()

Visuals

No response

Logs

No response

Activity

  1. JustinGrote commented on Nov 7, 2024

    @JustinGrote
    Collaborator

    Andy Jackson (@ajacks88) thanks for your submission!

    We can't reproduce, maybe you can help us narrow down your environment. The nature of this error almost always means that something else in your environment is loading an older or otherwise incompatible Microsoft.Extensions.Logging assembly before the PowerShell Editor Services starts.
    image

    1. If you Use Install Specific Version to rollback, does the issue still persist?
      image
    2. If you switch your session to PowerShell 7, does the issue persist?
    3. Do you have anything in your profile? If you disable your profile in the vscode settings, does the issue still occur?

    CC Andy Jordan (@andyleejordan) for 👀

  2. JustinGrote commented on Nov 7, 2024

    @JustinGrote
    Collaborator

    Andy Jordan (@andyleejordan) I think it might be time for us to start catching these methodNotFound exceptions during startup and reporting some added guidance in this regard.

  3. Azburkabas commented on Nov 7, 2024

    @Azburkabas

    I have the same problem. After update to v.2024.4.0 it can not load powershell 5.1 sessions (powershell 7 works but I need pwsh 5.1).

    Error code:
    The terminal process "C:\WINDOWS\SysWOW64\WindowsPowerShell\v1.0\powershell.exe '-NoProfile', '-ExecutionPolicy', 'Bypass', '-Command', 'Import-Module 'c:\Users\xxxxxxxxx.vscode\extensions\ms-vscode.powershell-2024.5.0\modules\PowerShellEditorServices\PowerShellEditorServices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' -HostProfileId 'Microsoft.VSCode' -HostVersion '2024.5.0' -BundledModulesPath 'c:\Users\xxxxxxxx.vscode\extensions\ms-vscode.powershell-2024.5.0\modules' -EnableConsoleRepl -StartupBanner "PowerShell Extension v2024.5.0
    Copyright (c) Microsoft Corporation.

    https://aka.ms/vscode-powershell
    Type 'help' to get help.
    " -LogLevel 'Normal' -LogPath 'c:\Users\xxxxxxx\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\logs\1730969275-a948b417-6923-477c-a612-450319746a041730968940191' -SessionDetailsPath 'c:\Users\xxxxxx\AppData\Roaming\Code\User\globalStorage\ms-vscode.powershell\sessions\PSES-VSCode-21020-286160.json' -FeatureFlags @() '" terminated with exit code: 1.

    [ERROR] - PowerShell Language Server process didn't start!

    When i roll back to v2024.2.2 it works just fine.

  4. Phillip-Ian commented on Nov 7, 2024

    @Phillip-Ian

    Nothing new to add, just reinforcing the issue. Exact same symptoms, and rolling back to v2024.2.2 did the trick.

  5. JustinGrote commented on Nov 9, 2024

    @JustinGrote
    Collaborator

    Andy Jackson (@ajacks88) Chris (@Phillip-Ian) Azburkabas we can't reproduce this anywhere, so we have to figure out what is different about your environment.

    • Have you tried with PowerShell 7 and do you still have the same problem? A reminder that PS 5.1 is best effort support but we certainly aren't making any moves to actively break it.
    • Have you tried on another computer, preferably with a clean profile and a clean modules folder with no third party modules installed?
    • If the "other computer" works, we will need a list of your installed modules and maybe we can identify an early loader, but in PS 5.1 we don't have access to isolation tech that we have in 7 and are possibly unlikely to solve an incompatability with that specific module and will recommend you use 7 instead (you can still author 5.1 scripts in 7)
  6. 11 remaining items

  7. JustinGrote commented on Nov 13, 2024

    @JustinGrote
    Collaborator

    #2538 reopened for historical as well, should be addressed and closed with whatever PR fixes this.

  8. JustinGrote commented on Nov 13, 2024

    @JustinGrote
    Collaborator

    For anyone else potentially experiencing this issue, please capture a diagnostic trace and upload to this issue. If you aren't getting the MEL logger exception, your issue may be different, but this is most likely being caused by the Serilog version bump as Andy Jordan (@andyleejordan) noted.

  9. changed the title [-]Unable to launch powershell extension terminal after vscode update today[/-] [+]2024.4.0: Unable to start when using Windows PowerShell if older Serilog is already present[/+] on Nov 13, 2024
  10. JustinGrote commented on Nov 14, 2024

    @JustinGrote
    Collaborator

    Hopefully PowerShell/PowerShellEditorServices#2197 fixes this. In the meantime please downgrade to the previous version.

  11. JustinGrote commented on Nov 14, 2024

    @JustinGrote
    Collaborator

    Hey everyone, thanks for your patience, Andy Jordan (@andyleejordan) should get out a preview release tomorrow that should have this fixed, we will notify here and if you still have issues let us know.

  12. jsantoro339as commented on Nov 18, 2024

    @jsantoro339as

    After updating the extension to the preview release I now get the following error

    hell.EditorServices.Commands.StartEditorServicesCommand.EndProcessing()

    == Press any key to close terminal ==
    Start-EditorServices : Method not found: 'Microsoft.Extensions.Logging.ILoggerFactory Serialog.SerialogLoggerFactoryExtensions.AddSerialog(Microsoft.Extensions.Logging.ILoggerFactory, Serialog.ILogger, Boolean)'.
    At line:1 char:148
    +...ices.psd1'; Start-EditorServices -HostName 'Visual Studio Code Host' ...
    +
    + CategoryInfo : NotSpecified: (Microsoft.Power...ServicesCommand:StartEditorServicesCommand) [Start-EditorServices], MissingMethodException
    + FullyQualifiedErrorId : PowerShellEditorServicesError,Microsoft.PowerShell.EditorServices.Commands.StartEditorServicesCommand

  13. JustinGrote commented on Nov 18, 2024

    @JustinGrote
    Collaborator

    jsantoro339as the new prerelease hasn't been released yet, very soon! We ran into an internal verification build problem, I expect Andy Jordan (@andyleejordan) will get that sorted today or tomorrow.

  14. JustinGrote commented on Nov 19, 2024

    @JustinGrote
    Collaborator

    It's out! Go to your extensions and choose "switch to pre-release" in the right click menu and let us know if this fixes it for you!

  15. jsantoro339as commented on Nov 19, 2024

    @jsantoro339as

    Justin Grote (@JustinGrote) Yes, I just updated it and it is working again. Thank you team, for addressing the issue and getting the fix out.

  16. andyleejordan commented on Nov 19, 2024

    @andyleejordan
    Member

    So glad to hear it!

  17. andyleejordan commented on Nov 19, 2024

    @andyleejordan
    Member

    Hey Andy Jackson (@ajacks88) Azburkabas Chris (@Phillip-Ian) the fix for this is in the pre-release version of the extension, can you all please give it a try? Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions