Subject: bug#61748: 27.2; Eglot should use shell-file-name when launching the language server for a remote file

From: [email-masked]
Date: Tue, 28 Feb 2023 14:59:32 +0100 (CET)

João Távora <[email-masked]> writes:
> Michael Albinus <[email-masked]> writes:
> 
> > You must set tramp-remote-path before accessing the remote server.
> > Try this:
> >
> >      ~/Source/Emacs/emacs/src/emacs -Q -l tramp
> >                                             \
> >         --eval '(add-to-list (quote tramp-remote-path) "~/bin")'
> >                               \
> >         /ssh:sshuser@localhost#2022:$REMOTE_FILE
> >                                               \
> >         -f eglot
> 
> This works, and this would explain the instability I saw earlier.
> Thanks.  I wonder if it fixes Jerôme's problem, too.
> 
No I've already got it setup as part of my config before I ever access
Tramp, which seems only logical: first configure the environment, then
try to use it.

Just to be clear, which problem are we talking about here? There were
two related problems in my report:

1. When told that the language server is `rust-analyzer`, Eglot fails
   to launch it. This is caused by the hardcoded `"sh" "-c"` in
   `eglot--cmd` and is fixed by using `(or shell-file-name "sh")
   (or shell-command-switch "-c")`, possibly with an added
   `with-connection-local-variables` as per Michael's mail.
   Or maybe by removing the whole `eglot--cmd` function since from
   the comment it looks like it only exists to call `stty raw` for
   remote files, and Eglot is the only package that tries to do that.
   This can only be fixed in Eglot since that's where it's hardcoded.

2. Eglot doesn't detect `rust-analyzer` automatically. This could be
   related to the fact that `rust-analyzer` is in a non-standard path
   or to some mix-up between the local and remote environments (e.g.
   if Eglot tries to detect the server on the local PC even though it
   would need the remote one), or something else altogether. It is not
   fixed by the abovementioned changes. 
   I have no idea how Eglot tries to determine which server it should
   use, and so no idea where to start looking for a solution.

Jérôme