joaotavora / eglot

A client for Language Server Protocol servers
GNU General Public License v3.0
2.22k stars 203 forks source link

Eglot should use `shell-file-name` when launching the server for a remote file #1175

Closed jeberger closed 1 year ago

jeberger commented 1 year ago

Steps to reproduce:

Expected result:

Eglot should start

Actual result:

Eglot asks Enter program to execute (or <host>:<port>):, then when I type rust-analyzer it fails with message [jsonrpc] Server exited with status 127. Looking at eglot-events-buffer, it is clear that eglot tried to use sh to start the server.

Partial fix

The server starts correctly if I change function eglot--cmd to use (or shell-file-name "sh") instead of plain "sh", e.g.:

(defun eglot--cmd (contact)
  "Helper for `eglot--connect'."
  (if (file-remote-p default-directory)
      ;; TODO: this seems like a bug, although it’s everywhere. For
      ;; some reason, for remote connections only, over a pipe, we
      ;; need to turn off line buffering on the tty.
      ;;
      ;; Not only does this seem like there should be a better way,
      ;; but it almost certainly doesn’t work on non-unix systems.
      (list (or shell-file-name "sh") "-c"
            (string-join (cons "stty raw > /dev/null;"
                               (mapcar #'shell-quote-argument contact))
                         " "))
    contact))

It still fails to autodetect the server and asks for the program to execute though.

joaotavora commented 1 year ago

Please report this to the Emacs bug tracker with M-x report-emacs-bug and put Michael Albinus and me in CC: or X-Debbugs-CC:. I have very little TRAMP experience.

jeberger commented 1 year ago

Please report this to the Emacs bug tracker with M-x report-emacs-bug and put Michael Albinus and me in CC: or X-Debbugs-CC:. I have very little TRAMP experience.

Done: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61748 but I couldn't put you or Michael Albinus in CC since I don't have your email addresses.

joaotavora commented 1 year ago

Closing. Let's continue in that bug. I've also reproduced the problem in the meantime, and it's indeed a bit annoying.