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

From: João Távora <[email-masked]>
Date: Tue, 28 Feb 2023 14:25:45 +0000

On Tue, Feb 28, 2023 at 1:59 PM <[email-masked]> wrote:

> > 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.

It may seem logical to you but since you didn't state this in your
original recipe, it's only logical that I wondered.

For me, a change to a variable should take effect immediately,
no reboots or restarts.  If you're satisfied with less, suit yourself
(maybe you're on M$ windows?).

> Just to be clear, which problem are we talking about here?

The one that I described fully with a full reproduction recipe,
a few messages ago.  It seemed very similar to your problem, so I
didn't think it was worth a separate bug report.

> 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.

Patches welcome.  Patches that remove code and don't break anything
even more welcome.  The patch you sent is insufficient, by your own
admission.  And Eli didn't like it either.

> 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.

Eglot uses (executable-find "rust-analyzer" t).  The second argument
asks to consider the remote path, but sometimes that path, which is
configured by tramp-remote-path isn't considered immediately. Michael
clarified this and I expressed the opinion that it is shortcoming
of Tramp.

João