Subject: bug#72861: 30.0.90; remote tramp (30.0.90): Couldn't find a proper `ls' command

From: Michael Albinus <[email-masked]>
Date: Fri, 30 Aug 2024 16:26:01 +0200

Christopher Howard <[email-masked]> writes:

Hi Christopher,

> I did this within an "emacs -q" session, and all the output in *debug tramp/ssh localhost* buffer is pasted below.

Thanks. Pls send the bug buffer as attachment next time; otherwise some
formatting is lost.

> From a quick glance at that, I wonder if the Emacs 30 version of tramp
> is looking for "ls" only in the certain standard directories like /bin
> and /usr/bin. On a guix system, however, no files are stored in these
> directories, except links to "sh" and "env", as executables are
> accessible from profile directories and the store via PATH.

Hmm, let's see what Tramp does. All checks are successful, until it
tries to determine the remote $PATH.

> 07:06:38.821548 tramp-send-command (6) # echo \"`getconf PATH 2>/dev/null`\" 2>/dev/null; echo tramp_exit_status $?
> 07:06:38.834376 tramp-wait-for-regexp (6) #
> "/bin:/usr/bin"
> tramp_exit_status 0
> ///ef73c2cb88ffee90faab20c0547acf27#$

This is what the underlying Linux says. Not su much, but there's also tramp-remote-path:

> 07:06:38.936774 tramp-send-command (6) # tramp_bundle_read_file_names () {
> echo "("
> while read file; do
>     quoted=`echo "$file" | sed -e "s/\"/\\\\\\\\\"/"`
>     printf "(%b" "\"$quoted\""
>     if test -e "$file"; then printf " %b" t; else printf " %b" nil; fi
>     if test -r "$file"; then printf " %b" t; else printf " %b" nil; fi
>     if test -d "$file"; then printf " %b)
> " t; else printf " %b)
> " nil; fi
> done
> echo ")"
> } 2>/dev/null; echo tramp_exit_status $?
> 07:06:38.937570 tramp-wait-for-regexp (6) #
> tramp_exit_status 0
> ///ef73c2cb88ffee90faab20c0547acf27#$

A shell script to be used.

> 07:06:38.938707 tramp-send-command (6) # tramp_bundle_read_file_names <<'6695bafbd64274a59417f8a21005f192' 2>/dev/null; echo tramp_exit_status $?
> /bin
> /usr/bin
> /sbin
> /usr/sbin
> /usr/local/bin
> /usr/local/sbin
> /local/bin
> /local/freeware/bin
> /local/gnu/bin
> /usr/freeware/bin
> /usr/pkg/bin
> /usr/contrib/bin
> /opt/bin
> /opt/sbin
> /opt/local/bin
> /opt/homebrew/bin
> /opt/homebrew/sbin
> 6695bafbd64274a59417f8a21005f192
> 07:06:38.986779 tramp-wait-for-regexp (6) #
> (
> ("/bin" t t t)
> ("/usr/bin" t t t)
> ("/sbin" nil nil nil)
> ("/usr/sbin" nil nil nil)
> ("/usr/local/bin" nil nil nil)
> ("/usr/local/sbin" nil nil nil)
> ("/local/bin" nil nil nil)
> ("/local/freeware/bin" nil nil nil)
> ("/local/gnu/bin" nil nil nil)
> ("/usr/freeware/bin" nil nil nil)
> ("/usr/pkg/bin" nil nil nil)
> ("/usr/contrib/bin" nil nil nil)
> ("/opt/bin" nil nil nil)
> ("/opt/sbin" nil nil nil)
> ("/opt/local/bin" nil nil nil)
> ("/opt/homebrew/bin" nil nil nil)
> ("/opt/homebrew/sbin" nil nil nil)
> )
> tramp_exit_status 0
> ///ef73c2cb88ffee90faab20c0547acf27#$

A check, whether the other directories exist. Hmm, they don't. Therefore

> 07:06:38.992727 tramp-send-command (6) # PATH=/bin:/usr/bin && export PATH
> 07:06:39.041141 tramp-wait-for-regexp (6) #
> ///ef73c2cb88ffee90faab20c0547acf27#$

And here we are. Just /bin:/usr/bin is in the PATH.

What's needed is, that you expand tramp-remote-path by the directories
guis keeps the system programs. See the Tramp manual (info "(tramp) Remote programs")

See also bug#64534. This is a Guix bug, that's why I haven't seen it
until now. But IIUC, Guix offers some Tramp config in its own version of
Emacs.

> Also, to be explicit: this was not a problem under 29.4 and goes away if I run my 29.4 executable again.

Hmm, I cannot comment, since I don't run Guix. Could it be that you have
used the Emacs package offered by Guix? As I understand bug#64534, it
comes with a suitable tramp-remote-path.

Best regards, Michael.