Subject: Re: 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 17:16:56 +0100 (CET)

Michael Albinus wrote:
> [email-masked] writes:
> 
> Hi Jérôme,
> 
> > Effectively, `(executable-find "rust-analyzer" t)` doesn't find it.
> 
> Your current buffer is a remote one when you call it, right?
> 
> > I'll try to find out why, but this point should indeed be fixed in
> > `executable-find` rather than Eglot.
> 
> Pls set tramp-verbose to 10, rerun the test, and show me the Tramp
> debug
> buffer. Something like
> 
> --8<---------------cut here---------------start------------->8---
> # emacs -Q -l tramp --eval '(setq tramp-verbose 10)' --eval
> '(add-to-list (quote tramp-remote-path) ...)' /ssh:user@host: --eval
> '(executable-find "rust-analyzer" t)'
> --8<---------------cut here---------------end--------------->8---
> 
> > Jérôme
> 
Yes, it's with a remote buffer. I also noticed that `(exec-path)` is
wrong: it only contains the standard paths ("/bin" "/usr/bin" "/sbin"
"/usr/sbin" "/usr/local/bin" "/usr/local/sbin") plus the path of the
current file. It's missing the paths from the remote environment and
the paths I've added manually to `tramp-remote-path`.

However `(shell-command "echo $PATH")` prints the correct path, and
`(shell-command "rust-analyzer --version")` works.

I tried with a minimalist emacs:

```
emacs -Q -l tramp \
    --eval '(setq tramp-verbose 10)' \
    --eval "(setq tramp-remote-path '(tramp-own-remote-path tramp-default-remote-path))" \
    --eval '(setq shell-file-name "zsh")' \
    /plink:user@host: \
    --eval '(message (exec-path))'
```

But Tramp ignores `shell-file-name` and uses `/bin/sh` instead. E.g.
in the Tramp debug buffer, I see lines like this:

```
16:53:16.188134 tramp-send-command (6) # /bin/sh -l -c 'echo 1e814d9777358b9e0b5ab89ad5422ddb \"$PATH\"' 2>/dev/null; echo tramp_exit_status $?
```

and when I call `shell-command`, it's clear that it's using `sh` too
even though `C-h v` shows that `shell-file-name` is correctly set to
`zsh`.

Jérôme