I'm running into this error when trying to load an auto generated autoload.el
file using loaddefs-generate
function. The following is how I did
;;; core-autoload.el -*- lexical-binding: t; -*-
(defvar generated-autoload-file nil
"This is neccessary, otherwise raise error.
`Defining as dynamic an already lexical var`.")
(defvar chidori-autoload-file
(expand-file-name "autoload.el" chidori-cache-dir)
"Autoload file.")
(defun chidori-autoload/generate-define (loaddef &rest DIRS)
"LOADDEF DIRS."
(let ((generated-autoload-file loaddef))
(when (or (not (file-exists-p generated-autoload-file))
noninteractive)
(loaddefs-generate DIRS chidori-autoload-file))))
(defun chidori-autoload/reload ()
"Generate autoload file from `core/autoload'."
(interactive)
(when (file-exists-p chidori-autoload-file)
(delete-file chidori-autoload-file t)
(message "delete old autoload file: %s" chidori-autoload-file))
(chidori-autoload/generate-define chidori-autoload-file chidori-autoload-dir)
(load chidori-autoload-file nil 'nomessage)
(message "generate autoload file: %s done." chidori-autoload-file))
(unless (file-exists-p chidori-autoload-file)
(chidori-autoload/reload))
(load chidori-autoload-file nil 'nomessage)
(provide 'core-autoload)
;; core-autoload.el ends here
And this is part of generated autoload file
;;; autoload.el --- automatically extracted autoloads (do not edit) -*- lexical-binding: t -*-
;; Generated by the `loaddefs-generate' function.
;; This file is part of GNU Emacs.
;;; Code:
;;; Generated autoloads from ../../autoload/package.el
(autoload 'package! "../../autoload/package")
;;; and many other autoloads
However, when I start Emacs, the error occurred saying it (file-missing "Cannot open load file" "No such file or directory" "../../autoload/package"
If I manually edit to absolute path, the issue is gone. But I don't think it's right way to do.
Can anyone help me out?
My draft for further reference:
https://git.sr.ht/~bangedorrunt/chidori-emacs
The following is my system information:
OS: macOS 12.6
Emacs versions: emacs-plus@29
Terminal: Wezterm
Shell: fish
CodePudding user response:
I finally figured out the issue.
In my config, I got
(defvar chidori-etc-dir (expand-file-name "etc/" user-emacs-directory))
(defvar chidori-cache-dir (expand-file-name "cache/" chidori-etc-dir))
The issue is fixed if I replace chidori-etc-dir
with the following
(defvar chidori-cache-dir (expand-file-name "cache/" user-emacs-directory))
From my understanding, we couldn't 2 level nested dir for autoload file. This also happen if I write autoload file to user-emacs-directory
.