Subject: Re: 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 00:00:04 +0000

Michael Albinus <[email-masked]> writes:

> João Távora <[email-masked]> writes:
>
> Hi João,
>
>>     Why don't you add (the expanded) ~/bin to tramp-remote-path?
>>
>> I did, but it did not work reliably, Michael. Only sometimes.
>>
>> I will try again though.
>
> Show me your settings, we'll fix it together.

I use the attached dockerfile that I used for the reproduction of
bug#61350.  It installs a Java LSP server and has a Java project.  I
build and run this Docker container with:

FROM ubuntu:latest
RUN apt update && apt install  openssh-server sudo openjdk-17-jdk openjdk-17-jre git wget -y
# Create a user “sshuser” and group “sshgroup”
RUN groupadd sshgroup && useradd -ms /bin/bash -g sshgroup sshuser
# Create sshuser directory in home
RUN mkdir -p /home/sshuser/.ssh
# Copy the ssh public key in the authorized_keys file. The idkey.pub below is a public key file you get from ssh-keygen. They are under ~/.ssh directory by default.
COPY id_rsa.pub /home/sshuser/.ssh/authorized_keys
# change ownership of the key file. 
RUN chown sshuser:sshgroup /home/sshuser/.ssh/authorized_keys && chmod 600 /home/sshuser/.ssh/authorized_keys
# Start SSH service
RUN service ssh start
# Expose docker port 22
EXPOSE 22

USER sshuser
WORKDIR /home/sshuser
RUN git clone --depth 1 --no-tags --single-branch -b eglot-tramp-freeze-repro https://github.com/thkoch2001/yacy_search_server
RUN wget https://download.eclipse.org/jdtls/milestones/1.19.0/jdt-language-server-1.19.0-202301171536.tar.gz
RUN mkdir jdtls
RUN tar xvfz jdt-language-server-1.19.0-202301171536.tar.gz -C jdtls
RUN mkdir bin
RUN ln -sf ~/jdtls/bin/jdtls ~/bin/jdtls

USER root
CMD ["/usr/sbin/sshd","-D"]

  docker build -t sshubuntu .
  docker run -d -p 2022:22 sshubuntu

In a directory where I have the attached dockerfile and a id_rsa.pub
which is the public key to my default ssh key.  

After this ssh access works with the user 'sshuser' on localhost port
2022 mapped to the server's 22.  The LSP server executable 'jdtls' is
linked to this user's $HOME/bin, or /home/sshuser/bin.

The default shell for user 'sshuser' is '/bin/bash' (though Tramp seems
to access it with '/bin/sh').  The local shell is '/bin/zsh'.

In the local machine I launch Emacs -Q sessions in slightly different
ways.  This fails:

    export REMOTE_FILE=/home/sshuser/yacy_search_server/source/net/yacy/yacy.java
    ~/Source/Emacs/emacs/src/emacs -Q                                                 \
       /ssh:sshuser@localhost#2022:$REMOTE_FILE                                       \
       --eval '(add-to-list (quote tramp-remote-path) "/home/sshuser/bin")'           \
       -f eglot

Even if it worked, I would be suboptimal.  I think I would like to avoid
the hardcoding of "/home/sshuser/bin" in my config.  This also fails.

    ~/Source/Emacs/emacs/src/emacs -Q                                                 \
       /ssh:sshuser@localhost#2022:$REMOTE_FILE                                       \
       --eval '(add-to-list (quote tramp-remote-path) "~/bin")'                       \
       -f eglot

And the following works.  Eglot is started correctly.

    ~/Source/Emacs/emacs/src/emacs -Q                                                 \
       /ssh:sshuser@localhost#2022:$REMOTE_FILE                                       \
       --eval '(add-to-list (quote tramp-remote-path) (quote tramp-own-remote-path))' \
       -f eglot

João