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>

To reply to this bug, email your comments to 78791 AT debbugs.gnu.org.
There is no need to reopen the bug first.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#78791; Package emacs. (Sat, 14 Jun 2025 19:24:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Alexis Bakatine <abakatine <at> proton.me>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 14 Jun 2025 19:24:05 GMT) Full text and rfc822 format available.

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

From: Alexis Bakatine <abakatine <at> proton.me>
To: "bug-gnu-emacs <at> gnu.org" <bug-gnu-emacs <at> gnu.org>
Subject: 30.1; Tramp reopening file with sudo after disconnect error message
Date: Sat, 14 Jun 2025 19:23:17 +0000
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.

Tested on Emacs 30.1 and 31.0.50 on Linux.

Best regards,

Alexis




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78791; Package emacs. (Sun, 15 Jun 2025 07:12:02 GMT) Full text and rfc822 format available.

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.




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78791; Package emacs. (Sun, 15 Jun 2025 07:13:02 GMT) Full text and rfc822 format available.

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#78791; Package emacs. (Mon, 16 Jun 2025 07:27:02 GMT) Full text and rfc822 format available.

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

From: Alexis Bakatine <abakatine <at> proton.me>
To: Michael Albinus <michael.albinus <at> gmx.de>
Cc: "78791 <at> debbugs.gnu.org" <78791 <at> debbugs.gnu.org>
Subject: Re: bug#78791: 30.1;
 Tramp reopening file with sudo after disconnect error message
Date: Mon, 16 Jun 2025 07:25:52 +0000
> 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.

It all makes sense better in my head now.

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

tramp-show-ad-hoc-proxies is working perfectly for what I described.

Thank you a lot for the explanation and solution Michael.
Feel free to close the non-bug and I wish you a great day.

Best regards,

Alexis




Added tag(s) notabug. Request was from Michael Albinus <michael.albinus <at> gmx.de> to control <at> debbugs.gnu.org. (Mon, 16 Jun 2025 08:15:02 GMT) Full text and rfc822 format available.

Reply sent to Michael Albinus <michael.albinus <at> gmx.de>:
You have taken responsibility. (Mon, 16 Jun 2025 08:17:02 GMT) Full text and rfc822 format available.

Notification sent to Alexis Bakatine <abakatine <at> proton.me>:
bug acknowledged by developer. (Mon, 16 Jun 2025 08:17:02 GMT) Full text and rfc822 format available.

Message #21 received at 78791-done <at> debbugs.gnu.org (full text, mbox):

From: Michael Albinus <michael.albinus <at> gmx.de>
To: Alexis Bakatine <abakatine <at> proton.me>
Cc: "78791 <at> debbugs.gnu.org" <78791-done <at> debbugs.gnu.org>
Subject: Re: bug#78791: 30.1; Tramp reopening file with sudo after
 disconnect error message
Date: Mon, 16 Jun 2025 10:16:19 +0200
Alexis Bakatine <abakatine <at> proton.me> writes:

Hi Alexis,

> tramp-show-ad-hoc-proxies is working perfectly for what I described.
>
> Thank you a lot for the explanation and solution Michael.
> Feel free to close the non-bug and I wish you a great day.

Thanks for the feedback, I'm closing the bug.

> Best regards,
>
> Alexis

Best regards, Michael.




This bug report was last modified 1 day ago.

Previous Next


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