GNU bug report logs -
#75983
project crash, file-name-directory "~", file-equal-p nil
Previous Next
Reported by: Ship Mints <shipmints <at> gmail.com>
Date: Sat, 1 Feb 2025 00:13:02 UTC
Severity: normal
Done: Dmitry Gutov <dmitry <at> gutov.dev>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 75983 in the body.
You can then email your comments to 75983 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75983
; Package
emacs
.
(Sat, 01 Feb 2025 00:13:02 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Ship Mints <shipmints <at> gmail.com>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Sat, 01 Feb 2025 00:13:02 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
The behaviors below can be seen on 29, 30, 31 (I don't have an earlier
Emacs to test but these issues probably are long-standing). Let's discuss
these as I suspect there may be historical reasons for these behaviors that
I'm unaware of, or maybe these are legitimate, even if old. It's also
possible that I'm misunderstanding something.
Issue 1:
(file-name-directory "~") ; returns nil but I think this should return "~/":
(file-name-directory
(abbreviate-file-name "/home/username")) ; same
(file-name-directory
(abbreviate-file-name "/Users/username")) ; for all us macOS users
Issue 2:
I think file-equal-p should accept nil and consider it unspecified as in
its docstring: "If FILE1 or FILE2 does not exist, the return value is
unspecified."
And/or find-file-name-handler should accept nil and then return nil.
(file-equal-p "~" "~") ; t
(file-equal-p "~" "/home/username") ; t
(file-equal-p "~" (file-name-directory "~")) ; boom
;; (wrong-type-argument stringp nil)
;; find-file-name-handler(nil file-equal-p)
Issue 3:
project-forget-projects-under crashes when `project-list-file' contains
"/home/username", which appears in my remembered project list.
(defun project--read-project-list ()
...
(abbreviate-file-name name) ; converts "/home/username" to "~"
(defun project-forget-projects-under ()
...
(dolist (proj (project-known-project-roots))
(when (file-equal-p (file-name-directory proj) dir) ; <--- boom on
nil
I'm happy to submit patches for any or all of these including guarding
project-forget-projects-under to check for nil and/or amending
project--read-project-list to convert "~" to "~/" as workarounds, with each
submitted against a discrete bug number.
-Stephane
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75983
; Package
emacs
.
(Sat, 01 Feb 2025 08:51:02 GMT)
Full text and
rfc822 format available.
Message #8 received at 75983 <at> debbugs.gnu.org (full text, mbox):
> From: Ship Mints <shipmints <at> gmail.com>
> Date: Fri, 31 Jan 2025 19:10:47 -0500
>
> The behaviors below can be seen on 29, 30, 31 (I don't have an earlier Emacs to test but these issues
> probably are long-standing). Let's discuss these as I suspect there may be historical reasons for these
> behaviors that I'm unaware of, or maybe these are legitimate, even if old. It's also possible that I'm
> misunderstanding something.
Thanks, but please don't mix separate issues in the same bug report.
If you think file-name-directory has a bug (I disagree), please report
a separate bug against file-name-directory. If you think file-equal-p
should accept nil as its argument (I'm not sure I will agree, but
maybe you will convince), please report a separate feature-request bug
about that function.
> Issue 3:
>
> project-forget-projects-under crashes when `project-list-file' contains "/home/username", which appears in
> my remembered project list.
It doesn't crash, it signals an error. Crashing means the entire
Emacs session goes down in flames.
> (defun project--read-project-list ()
> ...
> (abbreviate-file-name name) ; converts "/home/username" to "~"
>
> (defun project-forget-projects-under ()
> ...
> (dolist (proj (project-known-project-roots))
> (when (file-equal-p (file-name-directory proj) dir) ; <--- boom on nil
>
> I'm happy to submit patches for any or all of these including guarding project-forget-projects-under to check
> for nil and/or amending project--read-project-list to convert "~" to "~/" as workarounds, with each submitted
> against a discrete bug number.
I think this should be solved in project.el, but let's hear what
Dmitry (CC'ed) thinks.
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75983
; Package
emacs
.
(Sat, 01 Feb 2025 11:07:02 GMT)
Full text and
rfc822 format available.
Message #11 received at 75983 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
Separate bugs reports for sure, Eli, but I first thought it useful to
discuss holistically to illustrate. Let's consider this bug report to be
solely about project.
Dmitry, I think the following patch to project--write-project-list might
suffice to avoid this in the future:
diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index f2a27ff91dd..f9b3b8891bc 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -1824,7 +1824,7 @@ project--read-project-list
(lambda (elem)
(let ((name (car elem)))
(list (if (file-remote-p name) name
- (abbreviate-file-name name)))))
+ (file-name-as-directory (abbreviate-file-name
name))))))
(condition-case nil
(read (current-buffer))
(end-of-file
This causes /Users/xxx to appear as /Users/xxx/ in the project file and
then project--read-project-list produces ~/ rather than ~ for which
file-name-directory produces nil.
(defun project--read-project-list ()
...
(file-name-as-directory (abbreviate-file-name
name))))))
Note: I did not consider the tramp/remote file cases in this analysis.
On Sat, Feb 1, 2025 at 3:50 AM Eli Zaretskii <eliz <at> gnu.org> wrote:
> > From: Ship Mints <shipmints <at> gmail.com>
> > Date: Fri, 31 Jan 2025 19:10:47 -0500
> >
> > The behaviors below can be seen on 29, 30, 31 (I don't have an earlier
> Emacs to test but these issues
> > probably are long-standing). Let's discuss these as I suspect there may
> be historical reasons for these
> > behaviors that I'm unaware of, or maybe these are legitimate, even if
> old. It's also possible that I'm
> > misunderstanding something.
>
> Thanks, but please don't mix separate issues in the same bug report.
> If you think file-name-directory has a bug (I disagree), please report
> a separate bug against file-name-directory. If you think file-equal-p
> should accept nil as its argument (I'm not sure I will agree, but
> maybe you will convince), please report a separate feature-request bug
> about that function.
>
> > Issue 3:
> >
> > project-forget-projects-under crashes when `project-list-file' contains
> "/home/username", which appears in
> > my remembered project list.
>
> It doesn't crash, it signals an error. Crashing means the entire
> Emacs session goes down in flames.
>
> > (defun project--read-project-list ()
> > ...
> > (abbreviate-file-name name) ; converts "/home/username" to "~"
> >
> > (defun project-forget-projects-under ()
> > ...
> > (dolist (proj (project-known-project-roots))
> > (when (file-equal-p (file-name-directory proj) dir) ; <--- boom
> on nil
> >
> > I'm happy to submit patches for any or all of these including guarding
> project-forget-projects-under to check
> > for nil and/or amending project--read-project-list to convert "~" to
> "~/" as workarounds, with each submitted
> > against a discrete bug number.
>
> I think this should be solved in project.el, but let's hear what
> Dmitry (CC'ed) thinks.
>
[Message part 2 (text/html, inline)]
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75983
; Package
emacs
.
(Wed, 12 Feb 2025 02:51:02 GMT)
Full text and
rfc822 format available.
Message #14 received at 75983 <at> debbugs.gnu.org (full text, mbox):
Hi!
On 01/02/2025 13:04, Ship Mints wrote:
> Dmitry, I think the following patch to project--write-project-list might
> suffice to avoid this in the future:
>
> diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> index f2a27ff91dd..f9b3b8891bc 100644
> --- a/lisp/progmodes/project.el
> +++ b/lisp/progmodes/project.el
> @@ -1824,7 +1824,7 @@ project--read-project-list
> (lambda (elem)
> (let ((name (car elem)))
> (list (if (file-remote-p name) name
> - (abbreviate-file-name name)))))
> + (file-name-as-directory (abbreviate-file-
> name name))))))
> (condition-case nil
> (read (current-buffer))
> (end-of-file
Yeah, this is a decent solution, thanks.
Any idea though, how an entry without a trailing "/" got into that file?
Written by some older version of project.el?
Information forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#75983
; Package
emacs
.
(Wed, 12 Feb 2025 10:12:02 GMT)
Full text and
rfc822 format available.
Message #17 received at 75983 <at> debbugs.gnu.org (full text, mbox):
[Message part 1 (text/plain, inline)]
I don't know. Could have been from an older project, yes.
On Tue, Feb 11, 2025 at 9:49 PM Dmitry Gutov <dmitry <at> gutov.dev> wrote:
> Hi!
>
> On 01/02/2025 13:04, Ship Mints wrote:
> > Dmitry, I think the following patch to project--write-project-list might
> > suffice to avoid this in the future:
> >
> > diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
> > index f2a27ff91dd..f9b3b8891bc 100644
> > --- a/lisp/progmodes/project.el
> > +++ b/lisp/progmodes/project.el
> > @@ -1824,7 +1824,7 @@ project--read-project-list
> > (lambda (elem)
> > (let ((name (car elem)))
> > (list (if (file-remote-p name) name
> > - (abbreviate-file-name name)))))
> > + (file-name-as-directory (abbreviate-file-
> > name name))))))
> > (condition-case nil
> > (read (current-buffer))
> > (end-of-file
>
> Yeah, this is a decent solution, thanks.
>
> Any idea though, how an entry without a trailing "/" got into that file?
> Written by some older version of project.el?
>
[Message part 2 (text/html, inline)]
Reply sent
to
Dmitry Gutov <dmitry <at> gutov.dev>
:
You have taken responsibility.
(Wed, 12 Feb 2025 16:08:02 GMT)
Full text and
rfc822 format available.
Notification sent
to
Ship Mints <shipmints <at> gmail.com>
:
bug acknowledged by developer.
(Wed, 12 Feb 2025 16:08:02 GMT)
Full text and
rfc822 format available.
Message #22 received at 75983-done <at> debbugs.gnu.org (full text, mbox):
On 12/02/2025 12:10, Ship Mints wrote:
> I don't know. Could have been from an older project, yes.
All right. Well, no problem adding the conversion to account for similar
cases. Pushed to master as 2bb38cc46dfedfb1, closing.
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Thu, 13 Mar 2025 11:24:28 GMT)
Full text and
rfc822 format available.
This bug report was last modified 96 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.