On Sun, 28 Sept 2025 at 02:12, Rudi Horn via Bug reports for the GNU Bourne
Again SHell <[email protected]> wrote:

> I have been trying to diagnose an issue with LSP over TRAMP in Emacs,
> which I have documented in two github comments
> (https://github.com/emacs-lsp/lsp-mode/issues/2709#issuecomment-3311705879).
>
>

I've also responded on the github ticket, where there's more detail about
how you're invoking ssh.


> The essential problem I have been encountering, is that the stdin in is
> used to pass commands to the shell, and then input to a process spawned
> by the shell. Some of the bytes meant for the newly spanned process are
> consumed by bash read-ahead and thus don't make it to the spawned process.
>

The invocation `ssh -q … -o RemoteCommand=/bin/sh  -i $host` is unusual to
say the least. I'm going to assume that `-i` is part of the remote command,
since `ssh -i` would consume the following argument as the name of an
identity file, and ssh would then complain that you hadn't provided a
_host_ argument.

Forcing the shell into interactive mode using `-i` is only best-effort if
stdin is not a tty.

Without readline, the shell relies on the kernel's tty driver to split up
the input into lines. However if the stdin of `ssh` isn't a tty then it
won't ask `sshd` to provide a tty on the remote end unless you use `ssh
-tt`. (And the `stty` command is useless, for the same reason.)

Without a tty, the kernel simply hands over the maximum number of bytes
without regard for line boundaries, which consumes some of the input.

Question: does `lsp` need its stdin or stdout to be a tty?
And why is the shell in interactive mode?
(Are you trying to mimic a human?)

Consider either:
1. Sending the command to run as part of the `ssh` invocation, with the
input on stdin; run:
   ```
   ssh "$host" 'stty raw > /dev/null; echo READY; lsp'
   ```
   with whatever input you normally would use
2. Sending the script with its input as a heredoc:
   run
   ```
   ssh "$host" sh
   ```
   with input
   ```
   stty raw > /dev/null
   echo READY
   lsp <<\EndOfInput
   …input here…
   EndOfInput
   ```
3. Install a short script on the target host
   ```
   #!/bin/sh
   echo READY
   lsp
   ```
   and simply invoke that:
   ```
   ssh "$host" /path/to/script
   ```

-Martin
  • Stdin read-ahead ... Rudi Horn via Bug reports for the GNU Bourne Again SHell
    • Re: Stdin re... Chet Ramey
      • Re: Stdi... Chet Ramey
        • Re: ... Rudi Horn via Bug reports for the GNU Bourne Again SHell
          • ... Chet Ramey
            • ... Rudi Horn via Bug reports for the GNU Bourne Again SHell
              • ... Chet Ramey
                • ... Rudi Horn via Bug reports for the GNU Bourne Again SHell
    • Re: Stdin re... Martin D Kealey

Reply via email to