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

From: "Mark A. Hershberger" <[email-masked]>
Date: Sun, 15 Jun 2025 17:49:33 -0400

I was in the process of replying to your email (see below) and I
discovered what looks like an important hint.

I do not have an early-init.el, but when I start emacs I see a list of
loading files:

     $ emacs --init-directory=/home/mah/emacsd-test --eval '(progn (toggle-debug-on-error) (list-packages))'
     Loading /home/mah/.emacs.d/elpa/php-mode/lisp/php-mode-autoloads.el (source)...
     Loading /home/mah/.emacs.d/elpa/php-mode/lisp/php-mode-autoloads.el (source)...done
     Loading /home/mah/.emacs.d/elpa/password-store/contrib/emacs/password-store-autoloads.el (source)...
     Loading /home/mah/.emacs.d/elpa/password-store/contrib/emacs/password-store-autoloads.el (source)...done
     Loading /home/mah/.emacs.d/elpa/ghub/lisp/ghub-autoloads.el (source)...
     Loading /home/mah/.emacs.d/elpa/ghub/lisp/ghub-autoloads.el (source)...done
     Loading /home/mah/.emacs.d/elpa/forge/lisp/forge-autoloads.el (source)...
     Loading /home/mah/.emacs.d/elpa/forge/lisp/forge-autoloads.el (source)...done
     Loading /home/mah/.emacs.d/elpa/mastodon/lisp/mastodon-autoloads.el (source)...
     Loading /home/mah/.emacs.d/elpa/mastodon/lisp/mastodon-autoloads.el (source)...done

As you can see, it is loading them from ~/.emacs.d even though I told it
to use ~/emacsd-test for the init directory.

Further, each of those packages listed has :lisp-dir specified in my
customizations.  For example:

     (mastodon :url "https://codeberg.org/martianh/mastodon.el" :lisp-dir "lisp/")

There are other packages that have :lisp-dir specified, but removing
:lisp-dir for only those packages with an early auto-loader resolves the problem.

If it is still needed, here is what I started to reply:

Philip Kaludercic <[email-masked]> writes:

> Did you perhaps use `package-vc-install-from-checkout' on a directory
> you had checked out in /tmp/?

I did not, but something did.  I imagine this is part of the new :vc for
use-package.  My init.el includes the following:

    (use-package mastodon
      :vc (:url "https://codeberg.org/martianh/mastodon.el" :lisp-dir "lisp/" :rev :newest)
      :custom
      (mastodon-instance-url "https://fosstodon.org")
      (mastodon-active-user "hexmode"))

And, the following sequence:

    ~$ cd /tmp
    /tmp$ ls -ld /tmp/.git
    ls: cannot access '/tmp/.git': No such file or directory
    /tmp$ ls -ld /.git
    ls: cannot access '/.git': No such file or directory
    /tmp$ mkdir test
    /tmp$ cd test
    /tmp/test$ emacs --init-directory=/home/mah/emacsd-test --eval '(progn (toggle-debug-on-error) (list-packages))'

Results in the following backtrace:

    Debugger entered--Lisp error: (file-missing "Opening directory" "No such file or directory" "/tmp/test/lisp")
      directory-files("lisp/" t "\\.el\\'" t)
      package-vc-commit(#s(package-desc :name mastodon :version (2 0 1) :summary "Client for fediverse services using the Mastodon API" :reqs ((emacs (27 1)) (emacs (28 1)) (persist (0 4)) (tp (0 7))) :kind vc :archive nil :dir "/home/mah/emacsd-test/elpa/mastodon" :extras ((:commit . "f6247f0c9b8c15b19e8ddca2f600ceb2cf48beb9")) :signed nil))
      package-menu--print-info-simple(#s(package-desc :name mastodon :version (2 0 1) :summary "Client for fediverse services using the Mastodon API" :reqs ((emacs (27 1)) (emacs (28 1)) (persist (0 4)) (tp (0 7))) :kind vc :archive nil :dir "/home/mah/emacsd-test/elpa/mastodon" :extras ((:commit . "f6247f0c9b8c15b19e8ddca2f600ceb2cf48beb9")) :signed nil))
      package-menu--refresh(t nil)
      package-menu--generate(nil t)
      list-packages()
      (progn (toggle-debug-on-error) (list-packages))
      eval((progn (toggle-debug-on-error) (list-packages)) t)
      command-line-1(("--eval" "(progn (toggle-debug-on-error) (list-packages))"))
      command-line()
      normal-top-level()

Thanks,

Mark.