Re: tramp (2.8.0-pre nil/nil); Eglot does not work via direct-async process

Michael Albinus <[email protected]> Tue, 04 Feb 2025 10:14:38 +0100
Newsgroups gmane.emacs.tramp
Message-ID <[email protected]>
Jordan Ellis Coppard <[email protected]> writes:

> Hello Michael,

Hi Jordan,

> For my "jam" connection if I disable it being a direct-async-process
> eglot works fine; however if it is a direct-async-process eglot does not
> work. It looks like eglot can at least invoke the remote lsp but
> afterwards for whatever reason eglot thinks it dies.
>
> My guess is that eglot might be reading the response of an unrelated
> tramp command and eglot then fails to decode that response (since it's
> not meant for it) and dies as a result.

You might enable Eglot (or jsonrpc) traces in order to prove this.

> I wonder if it's possible to get this working nicely, especially since
> eglot is a built-in package. I did some searching and saw previous
> mentions of problems with lsp-mode and direct-async-process one of which
> you commented on but no resolution as of yet.

There is also bug#61350. Long discussion ...

It started with discussion of ssh settings (not relevant for you). But
then, the second part discusses the concurrent accept-process-output
problem, no proper solution 'tho.

And there's the difference that this bug does not discuss the direct
async case.

Anyway, I hope you'll find something useful in the Eglot traces. From
the Tramp pov, everything looks OK:

> 01:45:16.104210 tramp-send-command (6) # test -e /home/jammy/project/ 2>/dev/null; echo tramp_exit_status $?
> 01:45:16.105482 tramp-wait-for-regexp (6) #
> tramp_exit_status 0
> ///310e327f7778448f90c65a48eaaa112f#$

This is the last Tramp command send prior to the direct async call.

> 01:45:16.108552 tramp-handle-make-process (6) # podman exec -it -e TERM=dumb -u jammy --workdir /home/jammy/project jam-zevem /bin/sh --noediting --norc --noprofile -c cd /home/jammy/project/ && ( env INSIDE_EMACS\=31.0.50\,tramp\:2.8.0-pre HISTFILE\=\~/.tramp_history PATH\=/home/jammy/bin\:/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin ENV\=\'\' TMOUT\=0 LC_CTYPE\=\'\' CDPATH\= HISTORY\= MAIL\= MAILCHECK\= MAILPATH\= PAGER\=cat autocorrect\= correct\= /bin/sh -c stty\ raw\ \>\ /dev/null\;\ zls )

This is the direct async call. Looks proper to me (but lengthy
...). After the call, Tramp isn't involved anymore in that process.

> 01:45:16.109232 tramp-send-command (6) # (if test -h "/home/jammy/project/"; then echo t; else echo nil; fi) && \readlink --canonicalize-missing /home/jammy/project/ 2>/dev/null; echo tramp_exit_status $?
> 01:45:16.113969 tramp-wait-for-regexp (6) #
> nil
> /home/jammy/project
> tramp_exit_status 0
> ///310e327f7778448f90c65a48eaaa112f#$
> 01:45:16.269247 tramp-send-command (6) # (if test -h "/home/jammy/project/src/evm.zig"; then echo t; else echo nil; fi) && \readlink --canonicalize-missing /home/jammy/project/src/evm.zig 2>/dev/null; echo tramp_exit_status $?
> 01:45:16.274466 tramp-wait-for-regexp (6) #
> nil
> /home/jammy/project/src/evm.zig
> tramp_exit_status 0
> ///310e327f7778448f90c65a48eaaa112f#$

These are some other internal Tramp commands, they look normal.

One idea: Open a local shell in your Emacs, and call there

--8<---------------cut here---------------start------------->8---
# podman exec -it -e TERM=dumb -u jammy --workdir /home/jammy/project jam-zevem /bin/sh --noediting --norc --noprofile -c cd /home/jammy/project/ && ( env INSIDE_EMACS\=31.0.50\,tramp\:2.8.0-pre HISTFILE\=\~/.tramp_history PATH\=/home/jammy/bin\:/usr/local/sbin\:/usr/local/bin\:/usr/sbin\:/usr/bin\:/sbin\:/bin ENV\=\'\' TMOUT\=0 LC_CTYPE\=\'\' CDPATH\= HISTORY\= MAIL\= MAILCHECK\= MAILPATH\= PAGER\=cat autocorrect\= correct\= /bin/sh -c stty\ raw\ \>\ /dev/null\;\ zls )
--8<---------------cut here---------------end--------------->8---

See whether it comunicates.

> I hope you're well,

It's going better, fortunately.

> /Jordan

Best regards, Michael.