GNU bug report logs - #41489
`package-dir-info' fails on a directory with a non-saved file

Previous Next

Package: emacs;

Reported by: Paul Pogonyshev <pogonyshev <at> gmail.com>

Date: Sat, 23 May 2020 17:51:02 UTC

Severity: normal

Fixed in version 29.1

Done: Lars Ingebrigtsen <larsi <at> gnus.org>

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 41489 in the body.
You can then email your comments to 41489 AT debbugs.gnu.org in the normal way.

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#41489; Package emacs. (Sat, 23 May 2020 17:51:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Paul Pogonyshev <pogonyshev <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sat, 23 May 2020 17:51:02 GMT) Full text and rfc822 format available.

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

From: Paul Pogonyshev <pogonyshev <at> gmail.com>
To: bug-gnu-emacs <at> gnu.org
Subject: `package-dir-info' fails on a directory with a non-saved file
Date: Sat, 23 May 2020 19:50:02 +0200
[Message part 1 (text/plain, inline)]
To reproduce:

- edit any Elisp file, but don't save it;
- open its directory in Dired;
- evaluate `(package-dir-info)'.

Fails with: (file-missing "Opening input file" "No such file or directory"
".../.#blabla.el")

I.e. it tries to open the lock created for the unsaved file as a normal
file and fails. I'm not 100% sure this should be considered a bug, but from
my point of view it is so. Even if this is not a bug, the function should
probably fail with a more descriptive error.

Paul
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41489; Package emacs. (Sat, 23 May 2020 18:24:01 GMT) Full text and rfc822 format available.

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

From: Eli Zaretskii <eliz <at> gnu.org>
To: Paul Pogonyshev <pogonyshev <at> gmail.com>
Cc: 41489 <at> debbugs.gnu.org
Subject: Re: bug#41489: `package-dir-info' fails on a directory with a
 non-saved file
Date: Sat, 23 May 2020 21:23:15 +0300
> From: Paul Pogonyshev <pogonyshev <at> gmail.com>
> Date: Sat, 23 May 2020 19:50:02 +0200
> 
> - edit any Elisp file, but don't save it;
> - open its directory in Dired;
> - evaluate `(package-dir-info)'.
> 
> Fails with: (file-missing "Opening input file" "No such file or directory" ".../.#blabla.el")

In what version of Emacs is that?  Please always supply the
information collected by report-emacs-bug, as that saves unnecessary
questions such as this one.

Thanks.





Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41489; Package emacs. (Sat, 23 May 2020 18:38:02 GMT) Full text and rfc822 format available.

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

From: Paul Pogonyshev <pogonyshev <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 41489 <at> debbugs.gnu.org
Subject: Re: bug#41489: `package-dir-info' fails on a directory with a
 non-saved file
Date: Sat, 23 May 2020 20:37:20 +0200
[Message part 1 (text/plain, inline)]
Sorry. In any Emacs version. I tested with a fairly recently compiled
`master', but judging by the source code I checked out two minutes ago, the
bug is there currently too. The cause is this:

            (insert-file-contents (pop files))

This form is not inside `(ignore-errors ...)' and so any failure is
propagated out of `package-dir-info' too.

Paul

On Sat, 23 May 2020 at 20:23, Eli Zaretskii <eliz <at> gnu.org> wrote:

> > From: Paul Pogonyshev <pogonyshev <at> gmail.com>
> > Date: Sat, 23 May 2020 19:50:02 +0200
> >
> > - edit any Elisp file, but don't save it;
> > - open its directory in Dired;
> > - evaluate `(package-dir-info)'.
> >
> > Fails with: (file-missing "Opening input file" "No such file or
> directory" ".../.#blabla.el")
>
> In what version of Emacs is that?  Please always supply the
> information collected by report-emacs-bug, as that saves unnecessary
> questions such as this one.
>
> Thanks.
>
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41489; Package emacs. (Mon, 25 May 2020 22:56:01 GMT) Full text and rfc822 format available.

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

From: Paul Pogonyshev <pogonyshev <at> gmail.com>
To: Eli Zaretskii <eliz <at> gnu.org>
Cc: 41489 <at> debbugs.gnu.org
Subject: Re: bug#41489: `package-dir-info' fails on a directory with a
 non-saved file
Date: Tue, 26 May 2020 00:55:05 +0200
[Message part 1 (text/plain, inline)]
I also noticed that the error depends on the Moon phase, i.e. it is not
_always_ reproducible. The reason is that it depends on the random order of
elements in `(directory-files default-directory t "\\.el\\'" t)' result.

On Sat, 23 May 2020 at 20:37, Paul Pogonyshev <pogonyshev <at> gmail.com> wrote:

> Sorry. In any Emacs version. I tested with a fairly recently compiled
> `master', but judging by the source code I checked out two minutes ago, the
> bug is there currently too. The cause is this:
>
>             (insert-file-contents (pop files))
>
> This form is not inside `(ignore-errors ...)' and so any failure is
> propagated out of `package-dir-info' too.
>
> Paul
>
> On Sat, 23 May 2020 at 20:23, Eli Zaretskii <eliz <at> gnu.org> wrote:
>
>> > From: Paul Pogonyshev <pogonyshev <at> gmail.com>
>> > Date: Sat, 23 May 2020 19:50:02 +0200
>> >
>> > - edit any Elisp file, but don't save it;
>> > - open its directory in Dired;
>> > - evaluate `(package-dir-info)'.
>> >
>> > Fails with: (file-missing "Opening input file" "No such file or
>> directory" ".../.#blabla.el")
>>
>> In what version of Emacs is that?  Please always supply the
>> information collected by report-emacs-bug, as that saves unnecessary
>> questions such as this one.
>>
>> Thanks.
>>
>>
[Message part 2 (text/html, inline)]
[0001-Fix-random-errors-in-package-dir-info-caused-by-unre.patch (text/x-patch, attachment)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41489; Package emacs. (Tue, 26 May 2020 02:08:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Paul Pogonyshev <pogonyshev <at> gmail.com>, Eli Zaretskii <eliz <at> gnu.org>
Cc: 41489 <at> debbugs.gnu.org
Subject: Re: bug#41489: `package-dir-info' fails on a directory with a
 non-saved file
Date: Mon, 25 May 2020 19:07:38 -0700
Paul Pogonyshev <pogonyshev <at> gmail.com> writes:

> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
> index 9a6d1d7319..99ba5d7107 100644
> --- a/lisp/emacs-lisp/package.el
> +++ b/lisp/emacs-lisp/package.el
> @@ -1181,7 +1181,9 @@ package-dir-info
>              info)
>          (while files
>            (with-temp-buffer
> -            (insert-file-contents (pop files))
> +            ;; Skip unreadable files, e.g. locks for unsaved `.el'
> +            ;; buffers (bug#41489).
> +            (ignore-errors (insert-file-contents (pop files)))
>              ;; When we find the file with the data,
>              (when (setq info (ignore-errors (package-buffer-info)))
>                ;; stop looping,

Do we really want to ignore *any* error from insert-file-contents here?

Should we really run package-buffer-info if inserting the file fails?
Won't that reach (error "Package lacks a file header") and signal an
error anyways, just a different and more cryptic one?

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41489; Package emacs. (Tue, 26 May 2020 06:55:02 GMT) Full text and rfc822 format available.

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

From: Paul Pogonyshev <pogonyshev <at> gmail.com>
To: Stefan Kangas <stefankangas <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 41489 <at> debbugs.gnu.org
Subject: Re: bug#41489: `package-dir-info' fails on a directory with a
 non-saved file
Date: Tue, 26 May 2020 08:54:00 +0200
[Message part 1 (text/plain, inline)]
> Do we really want to ignore *any* error from insert-file-contents here?

Well, maybe that should be limited to `file-missing' instead (what actually
happens when it tries to read a lock file).

> Should we really run package-buffer-info if inserting the file fails?
> Won't that reach (error "Package lacks a file header") and signal an
> error anyways, just a different and more cryptic one?

`package-buffer-info' is already inside a different `ignore-errors', so it
will signal an error, but that error will be ignored and the file skipped.

I'm not attached to any particular way this bug is fixed. Please adjust it
yourself, the patch is only an example of how it could be done. This will
be faster than if we try to negotiate the best way and recreate the patch.

BTW, the bug being reproducible only in 50% of the cases makes it even more
important to be fixed from my point of view. Nothing is worse than
unspecified behavior when it's not justified by reasons like huge
performance gain in my opinion.

Paul

On Tue, 26 May 2020 at 04:07, Stefan Kangas <stefankangas <at> gmail.com> wrote:

> Paul Pogonyshev <pogonyshev <at> gmail.com> writes:
>
> > diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
> > index 9a6d1d7319..99ba5d7107 100644
> > --- a/lisp/emacs-lisp/package.el
> > +++ b/lisp/emacs-lisp/package.el
> > @@ -1181,7 +1181,9 @@ package-dir-info
> >              info)
> >          (while files
> >            (with-temp-buffer
> > -            (insert-file-contents (pop files))
> > +            ;; Skip unreadable files, e.g. locks for unsaved `.el'
> > +            ;; buffers (bug#41489).
> > +            (ignore-errors (insert-file-contents (pop files)))
> >              ;; When we find the file with the data,
> >              (when (setq info (ignore-errors (package-buffer-info)))
> >                ;; stop looping,
>
> Do we really want to ignore *any* error from insert-file-contents here?
>
> Should we really run package-buffer-info if inserting the file fails?
> Won't that reach (error "Package lacks a file header") and signal an
> error anyways, just a different and more cryptic one?
>
> Best regards,
> Stefan Kangas
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41489; Package emacs. (Tue, 26 May 2020 08:52:02 GMT) Full text and rfc822 format available.

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

From: Stefan Kangas <stefankangas <at> gmail.com>
To: Paul Pogonyshev <pogonyshev <at> gmail.com>
Cc: Eli Zaretskii <eliz <at> gnu.org>, 41489 <at> debbugs.gnu.org
Subject: Re: bug#41489: `package-dir-info' fails on a directory with a
 non-saved file
Date: Tue, 26 May 2020 10:51:14 +0200
Paul Pogonyshev <pogonyshev <at> gmail.com> writes:

>> Do we really want to ignore *any* error from insert-file-contents here?
>
> Well, maybe that should be limited to `file-missing' instead (what actually
> happens when it tries to read a lock file).

Sounds good.

>> Should we really run package-buffer-info if inserting the file fails?
>> Won't that reach (error "Package lacks a file header") and signal an
>> error anyways, just a different and more cryptic one?
>
> `package-buffer-info' is already inside a different `ignore-errors', so it
> will signal an error, but that error will be ignored and the file skipped.

Thanks for clarifying.  I didn't study this code recently.

> I'm not attached to any particular way this bug is fixed. Please adjust it
> yourself, the patch is only an example of how it could be done. This will
> be faster than if we try to negotiate the best way and recreate the patch.

I don't mean to discourage you from working on this, on the contrary.
We appreciate that you're working on a fix.

Best regards,
Stefan Kangas




Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41489; Package emacs. (Sun, 05 Dec 2021 01:14:02 GMT) Full text and rfc822 format available.

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

From: Lars Ingebrigtsen <larsi <at> gnus.org>
To: Paul Pogonyshev <pogonyshev <at> gmail.com>
Cc: 41489 <at> debbugs.gnu.org
Subject: Re: bug#41489: `package-dir-info' fails on a directory with a
 non-saved file
Date: Sun, 05 Dec 2021 02:13:29 +0100
Paul Pogonyshev <pogonyshev <at> gmail.com> writes:

> To reproduce:
>
> - edit any Elisp file, but don't save it;
> - open its directory in Dired;
> - evaluate `(package-dir-info)'.
>
> Fails with: (file-missing "Opening input file" "No such file or directory"
> ".../.#blabla.el")

I've now made it ignore nonexistent files in Emacs 29.

-- 
(domestic pets only, the antidote for overdose, milk.)
   bloggy blog: http://lars.ingebrigtsen.no




bug marked as fixed in version 29.1, send any further explanations to 41489 <at> debbugs.gnu.org and Paul Pogonyshev <pogonyshev <at> gmail.com> Request was from Lars Ingebrigtsen <larsi <at> gnus.org> to control <at> debbugs.gnu.org. (Sun, 05 Dec 2021 01:14:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sun, 02 Jan 2022 12:24:11 GMT) Full text and rfc822 format available.

This bug report was last modified 2 years and 76 days ago.

Previous Next


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