SofusA / roslyn-language-server

A wrapper around Roslyn language server which makes compatible with editors other than VSCode
MIT License
32 stars 4 forks source link

LSP failing at start on Windows #9

Closed celestialvigor closed 2 months ago

celestialvigor commented 2 months ago

First of all, this effort is very appreciated.

Steps taken: 1- put Microsoft.CodeAnalysis.LanguageServer in path. The exe is reachable from cmd. 2- ran: cargo install --git https://github.com/SofusA/roslyn-language-server 3- Uninstalled helix. Built your branch from source. 4- languages.toml:

[language-server.roslyn]
command = "roslyn-language-server"

[[language]]
name = "c-sharp"
language-servers = ["roslyn"]

The below logs are generated:

2024-09-09T11:33:26.374 helix_lsp::transport [ERROR] roslyn err <- "thread 'main' panicked at src/main.rs:41:10:\n"
2024-09-09T11:33:26.375 helix_lsp::transport [ERROR] roslyn err <- "Unable to parse response from server: expected value at line 1 column 1\n"
2024-09-09T11:33:26.375 helix_lsp::transport [ERROR] roslyn err <- "note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace\n"
2024-09-09T11:33:45.635 helix_lsp [ERROR] failed to initialize language server: request 0 timed out

Perhaps Windows support is not finished yet?

SofusA commented 2 months ago

I am not sure if this is a Windows specific error or not.

This error happens if the output of the command Microsoft.CodeAnalysis.LanguageServer.exe in Windows (and Microsoft.CodeAnalysis.LanguageServer on mac/linux) is not a json object with pipeName: string.

This definitely needs some better error logging.

What is the output if you run Microsoft.CodeAnalysis.LanguageServer.exe?

celestialvigor commented 2 months ago

Running it bare you'd get this:

> Microsoft.CodeAnalysis.LanguageServer.exe
Option '--logLevel' is required.
Option '--extensionLogDirectory' is required.

Description:

Usage:
  Microsoft.CodeAnalysis.LanguageServer [options]

Options:
  -?, -h, --help                                          Show help and usage information
  --version                                               Show version information
  --debug                                                 Flag indicating if the debugger should be launched on
                                                          startup. [default: False]
  --brokeredServicePipeName                               The name of the pipe used to connect to a remote process (if
                                                          one exists).
  --logLevel                                              The minimum log verbosity.
  <Critical|Debug|Error|Information|None|Trace|Warning>
  (REQUIRED)
  --starredCompletionComponentPath                        The location of the starred completion component (if one
                                                          exists).
  --telemetryLevel                                        Telemetry level, Defaults to 'off'. Example values: 'all',
                                                          'crash', 'error', or 'off'.
  --sessionId                                             Session Id to use for telemetry
  --sharedDependencies                                    Full path of the directory containing shared assemblies
                                                          (optional).
  --extension, --extensions                               Full paths of extension assemblies to load (optional).
  --extensionLogDirectory (REQUIRED)                      The directory where we should write log files to
SofusA commented 2 months ago

Hmm. I don't have much experience with Windows, so i cant really help.

I have tried to add some more logging. Can you try build again from main?

celestialvigor commented 2 months ago

With that and setting RUST_BACKTRACE to 'full'.

All logs during session:

2024-09-09T21:55:52.218 helix_view::theme [WARN] Theme: invalid modifier: "normal"
2024-09-09T21:55:52.219 helix_view::theme [WARN] Theme: invalid modifier: "normal"
2024-09-09T21:55:54.923 helix_lsp::transport [ERROR] roslyn err <- "thread 'main' panicked at C:\\Users\\user\\.cargo\\git\\checkouts\\roslyn-language-server-2e3877e54a0fa777\\3b35bd5\\src\\roslyn.rs:56:10:\n"
2024-09-09T21:55:54.923 helix_lsp::transport [ERROR] roslyn err <- "Unable to parse response from server: Content-Length: 115\n"
2024-09-09T21:55:54.923 helix_lsp::transport [ERROR] roslyn err <- "\n"
2024-09-09T21:55:54.923 helix_lsp::transport [ERROR] roslyn err <- "Stack backtrace:\n"
2024-09-09T21:55:54.923 helix_lsp::transport [ERROR] roslyn err <- "   0: <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "   1: <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "   2: <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "   3: <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "   4: <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "   5: <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "   6: <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "   7: <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "   8: <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "   9: <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "  10: <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "  11: <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "  12: <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "  13: BaseThreadInitThunk\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "  14: RtlUserThreadStart\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "stack backtrace:\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "   0:     0x7ff76d10f5ad - <unknown>\n"
2024-09-09T21:55:54.928 helix_lsp::transport [ERROR] roslyn err <- "   1:     0x7ff76d12c7d9 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "   2:     0x7ff76d10b771 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "   3:     0x7ff76d10f386 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "   4:     0x7ff76d1114f8 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "   5:     0x7ff76d1111a6 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "   6:     0x7ff76d111a28 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "   7:     0x7ff76d1118e7 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "   8:     0x7ff76d10ff1f - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "   9:     0x7ff76d111598 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "  10:     0x7ff76d13fb14 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "  11:     0x7ff76d13ffb0 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "  12:     0x7ff76cf94379 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "  13:     0x7ff76cf92ec6 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "  14:     0x7ff76cf981e5 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "  15:     0x7ff76cf9ea99 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "  16:     0x7ff76cf998f6 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "  17:     0x7ff76cf9abfc - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "  18:     0x7ff76d106b8e - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "  19:     0x7ff76cf9ec1c - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "  20:     0x7ff76d1323a4 - <unknown>\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "  21:     0x7fff0f717374 - BaseThreadInitThunk\n"
2024-09-09T21:55:54.929 helix_lsp::transport [ERROR] roslyn err <- "  22:     0x7fff1023cc91 - RtlUserThreadStart\n"
2024-09-09T21:55:59.868 helix_view::document [ERROR] Failed to copy metadata on write: The operation completed successfully. (os error 0)
celestialvigor commented 2 months ago

At surface value I'd say these are still vague. If so, don't trouble yourself, we can close this one. Thank you so much.

SofusA commented 2 months ago

Okay it could look like that you are using a version before they changed to named pipes.

Can you try to use this version instead? https://dev.azure.com/azure-public/vside/_artifacts/feed/vs-impl/NuGet/Microsoft.CodeAnalysis.LanguageServer.win-x64/overview/4.12.0-3.24458.2

SofusA commented 2 months ago

At surface value I'd say these are still vague. If so, don't trouble yourself, we can close this one. Thank you so much.

This line indicates that a jsonrpc message is being parsed instead of the expected named pipe output. I am almost certain that you should just update Microsoft.CodeAnalysis.LanguageServer to version 4.12 :smiley:

2024-09-09T21:55:54.923 helix_lsp::transport [ERROR] roslyn err <- "Unable to parse response from server: Content-Length: 115\n"
celestialvigor commented 2 months ago

It worked. You implemented pull diagnostics and integrated the lsp single-handedly. Incredible work. Thank you so much again.

SofusA commented 2 months ago

No problem. Glad i could help.

SofusA commented 2 months ago

If you could write a short description on how you put Microsoft.CodeAnalysis.LanguageServer in your path, and made the exe is reachable from cmd. Then i can add some better windows installation guide it to the readme

celestialvigor commented 2 months ago

Definitely. In the Artifacts page, ctrl+f highlighted about 5 results, I took the first one since the rest were for arm/linux. That misled me. It was likely due to the virtual scroll implementation in the html table that the rest of the results weren't found.

So I would say:

  1. Visit the public feed page, in the Artifacts tab, search for or scroll down until you find the Microsoft.CodeAnalysis.LanguageServer.win-x64 package. Make sure it's the latest version.
  2. Download the .nupkg file, unzip it via 7zip/winrar.
  3. Open the resulting folder, go to content\LanguageServer\win-x64, grab this folder's absolute path and place it as an entry in your system PATH.

No need for more depth. If someone dug around for a faster Helix C# lsp on Windows, 99% they'll know about PATH since that's how omnisharp is installed, they tried it first and that's why they're here.