Warn user to sync+rebuild on emacs' major version change

Byte-code is not generally compatible across major releases of Emacs,
and packages may have changed in that time. Best throw a more helpful
error than leave users to deal with the obscure errors that this can
cause.
This commit is contained in:
Henrik Lissner 2020-05-03 16:00:34 -04:00
parent 2ccb9cc8a3
commit 2c70b75c6c
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 18 additions and 8 deletions

View file

@ -32,14 +32,16 @@ one wants that.")
(cl-check-type file string)
(and (print! (start "Generating core autoloads..."))
(doom-cli--write-autoloads
file (doom-cli--generate-autoloads
(cl-loop for dir
in (append (list doom-core-dir)
(cdr (doom-module-load-path 'all-p))
(list doom-private-dir))
if (doom-glob dir "autoload.el") collect it
if (doom-glob dir "autoload/*.el") append it)
'scan))
file
(doom-cli--generate-emacs-version-check)
(doom-cli--generate-autoloads
(cl-loop for dir
in (append (list doom-core-dir)
(cdr (doom-module-load-path 'all-p))
(list doom-private-dir))
if (doom-glob dir "autoload.el") collect it
if (doom-glob dir "autoload/*.el") append it)
'scan))
(print! (start "Byte-compiling core autoloads file..."))
(doom-cli--byte-compile-file file)
(print! (success "Generated %s")
@ -105,6 +107,12 @@ one wants that.")
(print! "M-x doom/restart")
(print! "M-x doom/reload")))
(defun doom-cli--generate-emacs-version-check ()
`((unless (equal emacs-major-version (eval-when-compile emacs-major-version))
(signal 'doom-error
(list "Your installed (major) version of Emacs has changed"
"Run 'doom sync && doom build' to bring Doom up to speed")))))
(defun doom-cli--generate-var-cache (vars)
`((setq ,@(cl-loop for var in vars
append `(,var ',(symbol-value var))))))

View file

@ -101,6 +101,8 @@ Return t on success, nil otherwise (but logs a warning)."
;; `string-remove-suffix' is much cheaper (because it does no file sanity
;; checks during or after; just plain ol' string manipulation).
(load (string-remove-suffix ".el" file) noerror 'nomessage)
(doom-error
(signal (car e) (cdr e)))
((debug error)
(message "Autoload file error: %s -> %s" (file-name-nondirectory file) e)
nil)))