I am having issues with autoloading of elpa packages under different versions of emacs (under macOS if that matters).

My ~/.emacs.d is a link to somewhere else.

Take as an example amx

The loading works under emacs 25 and 27 but not under 28. The error is like Cannot open load file: No such file or directory, ../../../../../../../.emacs.d/elpa/28/amx-20210305.118/amx.el The load-path is correct for each version

The packages are loaded into a different path for each version using this code in early-init.el

(setq package-user-dir
   (format "elpa/%s" emacs-major-version) user-emacs-directory))

I think the issue is with the generated amx-autoloads.el file and is the last line

emacs 25 has no register-definition-prefixes

emacs 27

(if (fboundp 'register-definition-prefixes) (register-definition-prefixes "amx" '("amx-")))

emacs 28

(register-definition-prefixes "../../../../../../../.emacs.d/elpa/28/amx-20210305.118/amx" '("amx-"))

In this file the generated comments are

emacs 25 -

;;;### (autoloads nil "amx" "amx.el" (24783 47304 949021 880000))
;;; Generated autoloads from amx.el

emacs 27

;;;### (autoloads nil "amx" "../../../../../../../.emacs.d/elpa/27/amx-20210305.118/amx.el"
;;;;;;  "a034ecc8682671a85a9465e1b8dcc78e")
;;; Generated autoloads from ../../../../../../../.emacs.d/elpa/27/amx-20210305.118/amx.el

emacs 28

;;;### (autoloads nil "../../../../../../../.emacs.d/elpa/28/amx-20210305.118/amx"
;;;;;;  "../../../../../../../.emacs.d/elpa/28/amx-20210305.118/amx.el"
;;;;;;  (0 0 0 0))
;;; Generated autoloads from ../../../../../../../.emacs.d/elpa/28/amx-20210305.118/amx.el

So I think the problem is that emacs uses the relative path to a directrory in some places and uses the realpath (ie expands the symbolic link) rather than the path under ~/.emacs.d

How can I control the generation of the -autoloads.el files so that the expanded path is ideally not used as in emacs 25 or at least as in emacs 27 not really used.

I suspect that this question is the same issue but it has no answers

  • BTW, default-directory is buffer-local. It changes every time you visit a file in a different directory. Definitely a bug if it uses a relative path anywhere. Name of default directory of current buffer. It should be an absolute directory name; on GNU and Unix systems, these names start with /' or ~' and end with /'.` Oct 26, 2021 at 0:21
  • OK default-directory might not be the correct thing - the question is what exactly is used
    – mmmmmm
    Oct 26, 2021 at 7:45

1 Answer 1


It may be corrupted byte-compilation. Delete the .elc files and recompile with v28. Keep in mind that after you do, earlier versions will not work anymore. So you might want to use a test bed to see what the outcome is, without wrecking your current production config.

  • No I have a different directory for each lot of packages emacs version and the problem is in the generated -autoloads.el file
    – mmmmmm
    Oct 25, 2021 at 22:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.