Subject: bug#78770: 31.0.50; listing packages has become impossible without creating random lisp directories

From: "Mark A. Hershberger" <[email-masked]>
Date: Wed, 11 Jun 2025 22:22:34 -0400

Attempting to list packages consistently ends up with an error.  Backtrace:

Debugger entered--Lisp error: (file-missing "Opening directory" "No such file or directory" "/home/mah/lisp")
  package-vc-commit(#s(package-desc :name forge :version (0 5 3) :summary "Access Git forges from Magit" :reqs ((emacs (29 1)) (compat (30 1)) (closql (2 2 2)) (emacsql (4 3 1)) (ghub (4 3 2)) (let-alist (1 0 6)) (llama (0 6 3)) (magit (4 3 6)) (markdown-mode (2 7)) (seq (2 24)) (transient (0 9 0)) (yaml (1 2 0))) :kind vc :archive nil :dir "/home/mah/.emacs.d/elpa/forge" :extras ((:commit . "aaeec51cca677e678032c87c26d6024efd7c71c4")) :signed nil))
  package-menu--print-info-simple(#s(package-desc :name forge :version (0 5 3) :summary "Access Git forges from Magit" :reqs ((emacs (29 1)) (compat (30 1)) (closql (2 2 2)) (emacsql (4 3 1)) (ghub (4 3 2)) (let-alist (1 0 6)) (llama (0 6 3)) (magit (4 3 6)) (markdown-mode (2 7)) (seq (2 24)) (transient (0 9 0)) (yaml (1 2 0))) :kind vc :archive nil :dir "/home/mah/.emacs.d/elpa/forge" :extras ((:commit . "aaeec51cca677e678032c87c26d6024efd7c71c4")) :signed nil))
  package-menu--refresh(t nil)
  package-menu--generate(nil t)
  package-list-packages(nil)
  funcall-interactively(package-list-packages nil)
  command-execute(package-list-packages record)
  #<subr execute-extended-command>(nil "package-list-packages" nil)
  ad-Advice-execute-extended-command(#<subr execute-extended-command> nil "package-list-packages" nil)
  apply(ad-Advice-execute-extended-command #<subr execute-extended-command> (nil "package-list-packages" nil))
  execute-extended-command(nil "package-list-packages" nil)
  funcall-interactively(execute-extended-command nil "package-list-packages" nil)
  command-execute(execute-extended-command)

This problem was introduced with the following commit. Rolling back this
commit fixes the problem:

ef5c7ec4990a603ff476e2266c31ea055ac0b609
Author:     Philip Kaludercic <[email-masked]>
AuthorDate: Wed Apr 30 17:07:09 2025 +0200

Improve detection of VC package revisions

* lisp/emacs-lisp/package-vc.el (package-vc-commit): If the
package specification lists a :lisp-dir, use that to search for
Lisp files.

1 file changed, 3 insertions(+), 1 deletion(-)
 lisp/emacs-lisp/package-vc.el | 4 +++-

modified    lisp/emacs-lisp/package-vc.el
@@ -219,7 +219,9 @@ package-vc-commit
   ;; FIXME: vc should be extended to allow querying the commit of a
   ;; directory (as is possible when dealing with git repositories).
   ;; This should be a fallback option.
-  (cl-loop with dir = (package-desc-dir pkg-desc)
+  (cl-loop with dir = (let ((pkg-spec (package-vc--desc->spec pkg-desc)))
+                        (or (plist-get pkg-spec :lisp-dir)
+                            (package-desc-dir pkg-desc)))
            for file in (directory-files dir t "\\.el\\'" t)
            when (vc-working-revision file) return it
            finally return "unknown"))