Subject: bug#65666: Lockfiles break package-vc-install-from-checkout

From: Philip Kaludercic <[email-masked]>
Date: Fri, 01 Sep 2023 12:52:24 +0000

[email-masked] writes:

> Eli Zaretskii <[email-masked]> writes:
>> We should not try to native-compile lock files, obviously.  Some code
>> naïvely uses "*.el" to find all the Lisp files; it should filter out
>> lock files.
>
> Please see attached patch.
>
>> P.S. Please always say in what version of Emacs you see the problem
>> you report.  Bonus points for including all of the information
>> collected by report-emacs-bug about your system and Emacs
>> configurations.
>
> Thanks - I'm on 29.0.92. I'll include that information next time.
>
> From 7b38b0bfd8c9da08daf734f6d0062d31dd54b947 Mon Sep 17 00:00:00 2001
> From: Joseph Turner <[email-masked]>
> Date: Thu, 31 Aug 2023 23:11:53 -0700
> Subject: [PATCH] Don't native compile lock files
>
> * lisp/emacs-lisp/package.el (package--delete-directory):
> Check that each file exists before compiling.
> ---
>  lisp/emacs-lisp/package.el | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/lisp/emacs-lisp/package.el b/lisp/emacs-lisp/package.el
> index e1172d69bf0..52a538e0627 100644
> --- a/lisp/emacs-lisp/package.el
> +++ b/lisp/emacs-lisp/package.el
> @@ -2485,6 +2485,7 @@ compiled."
>    (when (featurep 'native-compile)
>      (cl-loop
>       for file in (directory-files-recursively dir "\\.el\\'")
> +     when (file-exists-p file)
>       do (comp-clean-up-stale-eln (comp-el-to-eln-filename file))))
>    (if (file-symlink-p (directory-file-name dir))
>        (delete-file (directory-file-name dir))

LGTM, but I wonder if there is a better way to detect lockfiles
specifically?  If not, I can imagine that just using `file-exists-p'
would a too broad check, in the sense that it could make it difficult to
find other issues?