GNU bug report logs - #50187
28.0.50; tramp is called from calendar

Previous Next

Package: emacs;

Reported by: sds <at> gnu.org

Date: Tue, 24 Aug 2021 15:07:02 UTC

Severity: normal

Tags: moreinfo

Found in version 28.0.50

Done: Stefan Kangas <stefankangas <at> gmail.com>

Bug is archived. No further changes may be made.

Full log


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

From: Sam Steingold <sds <at> gnu.org>
To: Lars Ingebrigtsen <larsi <at> gnus.org>
Cc: 50187 <at> debbugs.gnu.org
Subject: Re: bug#50187: 28.0.50; tramp is called from calendar
Date: Mon, 22 Aug 2022 12:18:05 -0400
> * Lars Ingebrigtsen <ynefv <at> tahf.bet> [2022-08-22 16:28:38 +0200]:
>
> Steingold <sds <at> gnu.org> writes:
>
>> I get this trace:
>>
>>   tramp-file-name-handler(file-readable-p "/scp:remote:/path/Contents/Resources/site-lisp/cal-move.so")
>>   calendar-cursor-to-visible-date((8 24 2021))
>>   calendar-generate-window(8 2021)
>>   calendar-basic-setup(nil)
>>   calendar()
>>   run-hooks(midnight-hook)
>>   apply(run-hooks midnight-hook)
>>   timer-event-handler([t 24869 56416 388128 86400 run-hooks (midnight-hook) nil 0])
>
> (I'm going through old bug reports that unfortunately weren't resolved
> at the time.)

Very nice of you, but, alas, I have no way to reliably reproduce it now.

> calendar-cursor-to-visible-date is an autoloaded function, so what's
> happening is that Emacs is trying to load the cal-move file -- and
> looking into "/scp:remote:/path/Contents/Resources/site-lisp/".
>
> Can something have put that in your load-path by any chance?

I don't think so.

I suspect that this is a part of the pattern I still observe when tramp
paths seep into `default-directory' in irrelevant buffers.

Basically, if I create a non-file buffer `*NFB*' (e.g., by calling
`list-packages' or `gnus') while inside a tramp buffer, the buffer `*NFB*'
inherits `default-directory' from the tramp buffer (unless a special
action is taken, like by `gnus'!) so when a future action involving disk
access is initiated from `*NFB*' (e.g., when `midnight-hook' autoloads
something), the file system local to `*NFB*' is checked first (because
`.' is a part of `load-path' so it is resolved against the tramp
`default-directory').

Maybe a solution is to _never_ inherit `default-directory' unless
there is a _reason_ for that.  E.g., `*vc-diff*' should not inherit
`default-directory' from `*vc*' implicitly, but by an explicit action.
However, this will break so much existing code that you wouldn't even
consider that.
On the other hand, "explicitly non-file" modes (like, e.g., `*Custom*'
or `*Help*') should probably reset `default-directory'.

I now evaluate this

--8<---------------cut here---------------start------------->8---
(dolist (b (buffer-list))
  (with-current-buffer b
    (when (and (null buffer-file-name)
               (not (eq major-mode 'dired-mode))
               (not (string-match " ?\\*.*\\(tramp\\|vc\\|diff\\)" (buffer-name)))
               (tramp-tramp-file-p default-directory))
      (message "Reset 'default-directory' in %s(%s) from %s"
               b (or buffer-file-name list-buffers-directory) default-directory)
      (setq default-directory (default-value 'default-directory))
      )))
--8<---------------cut here---------------end--------------->8---

whenever I have any trouble with tramp, and, e.g., today I saw

--8<---------------cut here---------------start------------->8---
Reset ’default-directory’ in  *Minibuf-1*(nil) from /scp:remote:/home/sds/
Reset ’default-directory’ in *Custom Themes*(nil) from /scp:remote:/home/sds/
Reset ’default-directory’ in  *eldoc for line-move-visual*(nil) from /scp:remote:/home/sds/
--8<---------------cut here---------------end--------------->8---

Thank you very much for your attention.

-- 
Sam Steingold (https://aphar.dreamwidth.org/) on darwin Ns 10.3.2113
https://lastingimpactpsychology.com https://steingoldpsychology.com
https://ffii.org https://thereligionofpeace.com http://think-israel.org
Please express your antipathy in the suicidal form.




This bug report was last modified 1 year and 135 days ago.

Previous Next


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