Subject: bug#41489: `package-dir-info' fails on a directory with a non-saved file

From: Stefan Kangas <[email-masked]>
Date: Mon, 25 May 2020 19:07:38 -0700

Paul Pogonyshev <[email-masked]> 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