Skip to content
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

Fails under TRAMP #324

Closed
artempyanykh opened this issue Nov 24, 2022 · 2 comments · Fixed by #329
Closed

Fails under TRAMP #324

artempyanykh opened this issue Nov 24, 2022 · 2 comments · Fixed by #329

Comments

@artempyanykh
Copy link

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

  • Operating system
    • Local: MacOS 13.0.1
    • Remote: Fedora 37
  • Branch: master
  • Emacs version: 28
  • .NET Runtime, CoreCLR or Mono Version: 6.0.110
@juergenhoetzel
Copy link
Collaborator

[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 added a commit to juergenhoetzel/emacs-fsharp-mode that referenced this issue Mar 19, 2023
Install "fsautocomplete" on the remote host if `default-directory' is
a tramp filename.

Add pipe-workaround for remote fsautocomplete processes: There seems
to be a problem related to CRLF coded input in remote fsautocomplete
processes. Wrapping the process using a cat pipe fixes the
issue.

Even when setting `process-connection-type' to nil or 'pipe there is
still a pseudo tty for the started remote process:
https://www.gnu.org/software/emacs/manual/html_node/tramp/Remote-processes.html#Remote-process-connection-type

Fixes fsharp#324
@juergenhoetzel
Copy link
Collaborator

Should be fixed by #329

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

Successfully merging a pull request may close this issue.

2 participants