fsharp / emacs-fsharp-mode

F# Emacs mode
Apache License 2.0
205 stars 62 forks source link

Fails under TRAMP #324

Closed artempyanykh closed 1 year ago

artempyanykh commented 1 year ago

Description

When I try to use eglot + FSAC under TRAMP things don't quite work:

  1. Server auto-install is not TRAMP aware
    1. It installs FSAC under local ~/.config/emacs/FsAutoComplete folder rather than the remote one,
    2. It tried to start the binary using full local path on the remote machine and fails.
  2. Even if I hack the integration to use FSAC from PATH and skip the auto-install; FSAC crashes on the remote machine with the following exception. Locally it doesn't crash.
    [stderr] [12:22:04.341 ERR] [Startup] Start - LSP mode crashed
    [stderr] System.AggregateException: One or more errors occurred. (Header does not end with expected 
    [stderr]  character sequence: Content-Length: 2180)
    [stderr]  ---> StreamJsonRpc.BadRpcHeaderException: Header does not end with expected 
    [stderr]  character sequence: Content-Length: 2180
    [stderr]    at StreamJsonRpc.HeaderDelimitedMessageHandler.ReadHeadersAsync(CancellationToken cancellationToken)
    [stderr]    at StreamJsonRpc.HeaderDelimitedMessageHandler.ReadCoreAsync(CancellationToken cancellationToken)
    [stderr]    at StreamJsonRpc.MessageHandlerBase.ReadAsync(CancellationToken cancellationToken)
    [stderr]    at StreamJsonRpc.JsonRpc.ReadAndHandleRequestsAsync()
    [stderr]    --- End of inner exception stack trace ---
    [stderr]    at Ionide.LanguageServerProtocol.Server.startWithSetup[client](FSharpFunc`2 setupRequestHandlings, Stream input, Stream output, FSharpFunc`2 clientCreator, FSharpFunc`2 customizeRpc) in /_//src/LanguageServerProtocol.fs:line 179
    [stderr]    at Ionide.LanguageServerProtocol.Server.startWithSetup[client](FSharpFunc`2 setupRequestHandlings, Stream input, Stream output, FSharpFunc`2 clientCreator, FSharpFunc`2 customizeRpc) in /_//src/LanguageServerProtocol.fs:line 179
    [stderr]    at Ionide.LanguageServerProtocol.Server.start@268-2.Invoke(FSharpFunc`2 customizeRpc) in /_//src/LanguageServerProtocol.fs:line 268
    [stderr]    at FsAutoComplete.Lsp.AdaptiveFSharpLspServerModule.startCore[a,b](a toolsPath, FSharpFunc`2 workspaceLoaderFactory) in /home/runner/work/FsAutoComplete/FsAutoComplete/src/FsAutoComplete/LspServers/AdaptiveFSharpLspServer.fs:line 3783
    [stderr]    at FsAutoComplete.Parser.lspFactory@136.Invoke(Unit unitVar0) in /home/runner/work/FsAutoComplete/FsAutoComplete/src/FsAutoComplete/Parser.fs:line 136
    [stderr]    at FsAutoComplete.Lsp.FSharpLspServerModule.start(FSharpFunc`2 startCore) in /home/runner/work/FsAutoComplete/FsAutoComplete/src/FsAutoComplete/LspServers/FsAutoComplete.Lsp.fs:line 2957

Repro steps

  1. Setup emacs-fsharp-mode + eglot,
  2. Open a project on a remote machine via TRAMP + ssh.

Related information

juergenhoetzel commented 1 year ago

[stderr] [12:22:04.341 ERR] [Startup] Start - LSP mode crashed [stderr] System.AggregateException: One or more errors occurred. (Header does not end with expected [stderr] character sequence: Content-Length: 2180)

I can confirm this issue. There seems to be a problem related to buffering CRLF coded input and tramp processes. Wrapping the remote process using a cat pipe fixes the issue:

sh -c  "cat|/home/juergen/.emacs.d/FsAutoComplete/netcore/fsautocomplete --adaptive-lsp-server-enabled"
juergenhoetzel commented 1 year ago

Should be fixed by #329