PowerShellEditorServices: Stdio mode broken since v3.0.0

Hi!

Kate is an awesome open source text editor made by the KDE folks, and it supports language servers. By default, they provide configurations for some popular languages, documented here: https://docs.kde.org/trunk5/en/kate/kate/kate-application-plugin-lspclient.html

I am trying to add PowerShell support in it, by using this config:

{
    "servers": {
        "powershell": {
            "command": ["pwsh", "-NoLogo", "-NoProfile", "-Command", "%{ENV:USERPROFILE}/Desktop/PowerShellEditorServices/PowerShellEditorServices/Start-EditorServices.ps1", "-BundledModulesPath", "%{ENV:USERPROFILE}/Desktop/PowerShellEditorServices", "-LogPath", "%{ENV:TEMP}/kate/logs.log", "-SessionDetailsPath", "%{ENV:TEMP}/kate/session.json", "-HostName", "Kate", "-HostProfileId", "KDE.Kate", "-HostVersion", "2.0.0", "-Stdio", "-LogLevel", "Normal"],
            "highlightingModeRegex": "^PowerShell$"
        }
    }
}

The server starts successfully, and recognizes symbols, but that’s it. Nothing else seems to work, definitions go-to, hover etc. This is the log:

2022-02-02 12:11:37.835 +05:30 [INF] highlight handler loaded
2022-02-02 12:11:38.942 +05:30 [INF] PSScriptAnalyzer settings file not found. Falling back to default rules
2022-02-02 12:11:43.975 +05:30 [FTL] Failed to handle request textDocument/hover 3
System.InvalidOperationException: Stack empty.
   at System.Collections.Generic.Stack`1.ThrowForEmptyStack()
   at System.Collections.Generic.Stack`1.Peek()
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.get_CurrentFrame() in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 153
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.get_CurrentRunspace() in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 137
   at Microsoft.PowerShell.EditorServices.Services.PowerShell.Host.PsesInternalHost.Microsoft.PowerShell.EditorServices.Services.PowerShell.Runspace.IRunspaceContext.get_CurrentRunspace() in D:\a\1\s\src\PowerShellEditorServices\Services\PowerShell\Host\PsesInternalHost.cs:line 151
   at Microsoft.PowerShell.EditorServices.Services.SymbolsService.FindSymbolDetailsAtLocationAsync(ScriptFile scriptFile, Int32 lineNumber, Int32 columnNumber) in D:\a\1\s\src\PowerShellEditorServices\Services\Symbols\SymbolsService.cs:line 327
   at Microsoft.PowerShell.EditorServices.Handlers.PsesHoverHandler.Handle(HoverParams request, CancellationToken cancellationToken) in D:\a\1\s\src\PowerShellEditorServices\Services\TextDocument\Handlers\HoverHandler.cs:line 49
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.SemanticTokensDeltaPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.LanguageServer.Server.Pipelines.ResolveCommandPipeline`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPreProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestPostProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at MediatR.Pipeline.RequestExceptionActionProcessorBehavior`2.Handle(TRequest request, CancellationToken cancellationToken, RequestHandlerDelegate`1 next)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.<RouteRequest>g__InnerRoute|7_0(IServiceScopeFactory serviceScopeFactory, Request request, TDescriptor descriptor, Object params, CancellationToken token, ILogger logger)
   at OmniSharp.Extensions.JsonRpc.RequestRouterBase`1.RouteRequest(IRequestDescriptor`1 descriptors, Request request, CancellationToken token)
   at OmniSharp.Extensions.JsonRpc.DefaultRequestInvoker.<>c__DisplayClass10_0.<<RouteRequest>b__5>d.MoveNext()

I’m using PowerShell 7.1.2 on Windows 10 21H2.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 24 (14 by maintainers)

Most upvoted comments

I had the same issue when trying to use the builtin Neovim LSP client. I tried some older versions of the PowerShell Editor Services, release 2.5.3 works fine for me so far. Seems like this is broken since 3.0

Just had a chance to test on Linux and got the exact same behavior. 3.1.2 and 3.1.3 lead to the error message from the original post, 2.5.3 works.

Hey all, I really didn’t want this to happen again, so I’ve setup a full regression test against Eglot (an Emacs LSP client using PSES over stdio).

@andschwa didn’t find anything, it just works!

Thanks for fixing and have a nice weekend 😄

I think I got this solved! It was…a doozy. Had a few issues to fix. Tested successfully with eglot in Emacs. Will get a release out ASAP (today is the plan!) and hope you all can test in your various environments with different clients.

Getting to work on this now!

@andschwa Appreciate the work, thanks for the update 👍

Sorry if I came off a bit judgy / demanding, I was just a bit frustrated. It’s now working in the 2.5 release and I’m having a blast working with PowerShell completely in the console 😊

But if I understand this correctly, does this mean that the versions 3.0.0+ are neither working in VSCode nor in stdio based editors? Maybe it would then make sense to mark them as pre-releases so that people don’t get confused.

Wow! Thank you, you’re a genius 😃

2.5.3 works perfect.

Seems like this is broken since 3.0

It looks like there was a major refactor, which broke it for stdio mode.