GNU bug report logs - #78791
30.1; Tramp reopening file with sudo after disconnect error message

Previous Next

Package: emacs;

Reported by: Alexis Bakatine <abakatine <at> proton.me>

Date: Sat, 14 Jun 2025 19:24:03 UTC

Severity: normal

Tags: notabug

Found in version 30.1

Done: Michael Albinus <michael.albinus <at> gmx.de>

Full log


Message #8 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Alexis Bakatine via "Bug reports for GNU Emacs, the Swiss army knife of
 text editors" <bug-gnu-emacs <at> gnu.org>
Cc: Alexis Bakatine <abakatine <at> proton.me>, 78791 <at> debbugs.gnu.org
Subject: Re: bug#78791: 30.1; Tramp reopening file with sudo after
 disconnect error message
Date: Sun, 15 Jun 2025 09:11:45 +0200
Alexis Bakatine via "Bug reports for GNU Emacs, the Swiss army knife of
text editors" <bug-gnu-emacs <at> gnu.org> writes:

Hi Alexis,

> Hello, when I'm trying to open a file from a Dired buffer with sudo after a
> disconnect with Tramp, it results in an error message.
>
> How to reproduce:
>
> 1. emacs -Q '/ssh:foo <at> bar|sudo::'
> 2. M-x tramp-cleanup-all-connections
> 3. 'o' or <RET> to open a file
>
> result in *Messages*:
> Host name 'bar' does not match ‘\`\(?:t480s\|\(?:127\.0\.0\.1\|::1\|ip\(?:6-lo\(?:calhost\|opback\)\|v6-lo\(?:calhost\|opback\)\)\|localhost[46]?\)\)\'’
>
> Note that when NOT using sudo as with /ssh:foo <at> bar:, I can run M-x
> tramp-cleanup-all-connections and open a file without problem,
> Tramp reconnects automatically.

This is not an error. It is expected behavior.

The notion '/ssh:foo <at> bar|sudo::' is called ad-hoc multi-hop for a reason
in the Tramp manual. If you open it, you will see a dired buffer like
"/sudo:root <at> bar:~/" - note, that the leading "/ssh:foo <at> bar:" part is not
contained there. Tramp knows internally, that it should use this first
hop when accessing "/sudo:root <at> bar:".

However, when you call tramp-cleanup-all-connections, this information
is removed (by intention, in order to cleanup). When you reopen a file,
"/sudo:root <at> bar:" cannot be connected again due to the missing first hop
information.

The Tramp manual discusses this case, see (info "(tramp) Ad-hoc multi-hops")

--8<---------------cut here---------------start------------->8---
   Ad-hoc definitions are removed from ‘tramp-default-proxies-alist’ via
the command ‘M-x tramp-cleanup-all-connections <RET>’ (*note Cleanup
remote connections::).
--8<---------------cut here---------------end--------------->8---

I recommend you to set either tramp-show-ad-hoc-proxies or
tramp-save-ad-hoc-proxies to t.

> Best regards,
>
> Alexis

Best regards, Michael.




This bug report was last modified 2 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.