Skip to content

The server never answers to a initialize request on Windows over stdio (but it does on Linux) (takes too long loading libraries on Windows) #2092

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
3 tasks done
TheLeoP opened this issue Oct 20, 2023 · 6 comments

Comments

@TheLeoP
Copy link
Contributor

TheLeoP commented Oct 20, 2023

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest version
  • Search the existing issues.

Steps to reproduce

I'm using Neovim as my editor, so I'm using the minimal reproduction of this issue (but using the Diagnostic log level for powershellEditorServices).

  1. Open neovim on windows
  2. Open the file a.ps1
  3. Nothing happens (the server never answers the initiliaze request. There is more info on the logs)

If the same things are done on linux, everything works as expected.

Expected behavior

PowershellEditorServices should answer the `initialize` request in both windows and linux.

Actual behavior

PowershellEditorServices does not answer the `initiliaze` request on Windows (there is more info in the logs)

Error details

No response

Environment data

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

Version

3.13

Visuals

Powershell logs on Linux (everything works fine here):
pwsh_linux.log

Neovim LSP logs on Linux (everything works fine here):
neovim_linux.log

Powershell logs on Windows (it looks like the server takes too long loading some libraries and then cancels the initialize request):
pwsh_windows.log

Neovim logs on Windows (there is never a response for the initialize requets)
neovim_windows.log

@TheLeoP TheLeoP changed the title The server never answers to a initialize request on Windows over stdio (but it does on Linux) (takes too long loading libraries) The server never answers to a initialize request on Windows over stdio (but it does on Linux) (takes too long loading libraries on Windows) Oct 20, 2023
@andyleejordan
Copy link
Member

You know, I think maybe it's getting stuck loading your profile on Windows? Because I see this line:

2023-10-20 11:54:05.097 -05:00 [DBG] Loading profiles...

but never the accompanying line:

                _logger.LogDebug("Profiles loaded!");

which means it never finishes initializing (and therefore doesn't answer the request).

@TheLeoP
Copy link
Contributor Author

TheLeoP commented Oct 20, 2023

@andyleejordan

I'm new to powershell, so sorry for my lack of knowledge. I guess that using the parameter -NoProfile has no effect on this, right? Do you have any idea about why it would be stuck loading my profiles? Or how I could test this without my profiles to check if that's the problem?

Because, on the issue I linked (this one) people are having the same problem on Windows when everything works fine on Linux.

@andyleejordan
Copy link
Member

andyleejordan commented Oct 20, 2023

That's right. I would try setting enableProfileLoading to false in the initialization options you're setting the server up with. -NoProfile is parsed by the pwsh executable, which is in essence just the host program that runs the LSP server, and that server has its own logic to enable (or disable) profile loading. Users on Linux don't usually have anything in any of the multiple profile paths that are checked, but often do on Windows because some of them are shared.

@scottmckendry
Copy link

@andyleejordan confirming that this is the same issue I was having on #2048. Removing my profile, the LSP starts and works as expected. However, I'm not sure how I go about setting the value of enableProfileLoading.

It seems that neovim's LSP doesn't implement it. Is there a way I can pass it in as a parameter to Start-EditorServices? Or some other config file?

@TheLeoP
Copy link
Contributor Author

TheLeoP commented Oct 21, 2023

@andyleejordan Thaaaaaaaaaaaaaanks, that was it.

@scottmckendry You only need to do the following:

      require("lspconfig").powershell_es.setup {
        bundle_path = "path/to/your/bundle_path",
        init_options = {
          enableProfileLoading = false,
        },
      }

@andyleejordan
Copy link
Member

Glad to help and happy it's working for you! I'm sorry the setup for PSES for Vim/Emacs etc. is not the greatest. It's been on our docket to simplify and clean up for a long time but I keep getting pulled into other work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants