Subject: Re: bug#78572: 30.1; Tramp Project error message loop - File is missing

From: Ship Mints <[email-masked]>
Date: Wed, 28 May 2025 17:10:48 -0400

On Wed, May 28, 2025 at 5:05 PM Alexis Bakatine via Bug reports for GNU
Emacs, the Swiss army knife of text editors <[email-masked]> wrote:

> Hello Michael,
>
> > What you've sent didn't help; the problem is indicated much earlier in
> > the debug file. This is why I always insist in sending the whole debug
> > information.
>
> I apologize, I thought it was just irrelevant noise until what looped over
> and over, but it was indeed crucial.
>
> All your explanations make sense now. But I'm still not sure if it's an
> issue with Tramp or Project? Trivially speaking, we could also ask Project
> to not look for vc related information over Tramp, but maybe some people
> rely on this? After all, I'm the first one to report that bug as far as I
> know.
>
> > sudo's session timeout after ca 5 minutes due to inactivity on the
> > wire.
>
> This led me to investigate something. I told you it happened when
> using Tramp with sudo. But now I tested it WITHOUT sudo and I can
> reproduce the same errors. Here are the steps:
>
> 1. start an Emacs session with the command below (replace "x" with your own
>    server)
>
> --8<---------------cut here---------------start------------->8---
> # emacs -Q -l project --eval '(setopt project-vc-extra-root-markers (quote
> (".project")))' --eval '(setopt project-mode-line t)' '/ssh:x:'
> --8<---------------cut here---------------end--------------->8---
>
> 2. after successfuly connecting do:
>    M-x tramp-cleanup-all-connections
>
> As soon as the connection is closed the same errors happen.
>
> > --8<---------------cut here---------------start------------->8---
> > (add-to-list 'tramp-connection-properties (list (regexp-quote
> "/sudo:root <at> x:") "session-timeout" nil))
> > --8<---------------cut here---------------end--------------->8---
>
> > Does this work for you?
>
> I did try it in my init.el, and it cancels the automatic disconnect, but as
> soon as I M-x tramp-cleanup-all-connections or simply kill the process,
> the errors appear.
>
> I can live without having the project name in the mode line, so I removed
> (setopt project-mode-line t)
> but kept (setopt project-vc-extra-root-markers (quote (".project")))
>
> It seems the problem doesn't happen anymore (tested with 30.1 and master),
> yet I'm almost confident even with that setting only it was crashing
> Emacs at some point, I will try in my main config to see if it happens
> again later.
>

If this continues to be a concern, you can easily wrap the project mode
line with a remote file guard.  Maybe something like this:

  (setq project-mode-line-format '(:eval (my/project-mode-line-format)))
  (defun my/project-mode-line-format ()
    (unless (file-remote-p default-directory)
      (project-mode-line-format)))

You could make the guard sensitive to a custom variable of your own or to
the directory tree root or whatever makes sense for you.

-Stephane