Straight throws an 'emacs-version-changed' error if you load it with a version of Emacs it wasn't compiled with. This update causes this to emit a more helpful error.
This commit is contained in:
parent
87fd81281f
commit
c3e2ec0157
2 changed files with 18 additions and 16 deletions
|
@ -1,7 +1,6 @@
|
||||||
;;; -*- lexical-binding: t; no-byte-compile: t; -*-
|
;;; -*- lexical-binding: t; no-byte-compile: t; -*-
|
||||||
|
|
||||||
(require 'seq)
|
(require 'seq)
|
||||||
(require 'straight nil t)
|
|
||||||
|
|
||||||
|
|
||||||
(defvar doom-auto-accept (getenv "YES")
|
(defvar doom-auto-accept (getenv "YES")
|
||||||
|
|
|
@ -168,35 +168,38 @@ necessary package metadata is initialized and available for them."
|
||||||
(defun doom-ensure-straight ()
|
(defun doom-ensure-straight ()
|
||||||
"Ensure `straight' is installed and was compiled with this version of Emacs."
|
"Ensure `straight' is installed and was compiled with this version of Emacs."
|
||||||
(defvar bootstrap-version)
|
(defvar bootstrap-version)
|
||||||
(let* ((straight-dir (expand-file-name "straight/" doom-local-dir))
|
(let* (;; Force straight to install into ~/.emacs.d/.local/straight instead of
|
||||||
(bootstrap-file (expand-file-name "repos/straight.el/straight.el" straight-dir))
|
|
||||||
(bootstrap-version 5)
|
|
||||||
;; Force straight to install into ~/.emacs.d/.local/straight instead of
|
|
||||||
;; ~/.emacs.d/straight by pretending `doom-local-dir' is our .emacs.d.
|
;; ~/.emacs.d/straight by pretending `doom-local-dir' is our .emacs.d.
|
||||||
(user-emacs-directory doom-local-dir))
|
(user-emacs-directory doom-local-dir)
|
||||||
(cl-block 'straight
|
(straight-dir (doom-path doom-local-dir "straight/"))
|
||||||
|
(build-file (doom-path straight-dir "build/straight/straight.elc"))
|
||||||
|
(bootstrap-file (doom-path straight-dir "repos/straight.el/straight.el"))
|
||||||
|
(bootstrap-version 5))
|
||||||
|
(cl-block nil
|
||||||
;; Straight will throw `emacs-version-changed' if it's loaded with a
|
;; Straight will throw `emacs-version-changed' if it's loaded with a
|
||||||
;; version of Emacs that doesn't match the one it was compiled with.
|
;; version of Emacs that doesn't match the one it was compiled with.
|
||||||
;; Getting this error isn't very good UX...
|
;; Getting this error isn't very good UX...
|
||||||
(catch 'emacs-version-changed
|
(catch 'emacs-version-changed
|
||||||
(if (or (featurep 'staight)
|
(unless (featurep 'staight)
|
||||||
(load (file-name-sans-extension bootstrap-file) t t))
|
(unless (or (load build-file 'noerror 'nomessage)
|
||||||
(cl-return-from 'straight t)
|
(load bootstrap-file 'noerror 'nomessage))
|
||||||
(unless (file-exists-p bootstrap-file)
|
|
||||||
(with-current-buffer
|
(with-current-buffer
|
||||||
(url-retrieve-synchronously
|
(url-retrieve-synchronously
|
||||||
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
|
"https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
|
||||||
'silent 'inhibit-cookies)
|
'silent 'inhibit-cookies)
|
||||||
(goto-char (point-max))
|
(goto-char (point-max))
|
||||||
(eval-print-last-sexp)))
|
(eval-print-last-sexp))
|
||||||
(load bootstrap-file nil 'nomessage))
|
(load bootstrap-file nil 'nomessage)))
|
||||||
(cl-return-from 'straight t))
|
(cl-return t))
|
||||||
;; ...so we transform it into a more graceful error message:
|
;; Get rid of old build files
|
||||||
|
(when-let (build-dir (file-exists-p! "build/straight" straight-dir))
|
||||||
|
(delete-directory build-dir 'recursive))
|
||||||
|
;; Then transform the error into a more graceful failure message:
|
||||||
(with-temp-buffer
|
(with-temp-buffer
|
||||||
(insert-file-contents-literally (doom-path straight-dir "build-cache.el"))
|
(insert-file-contents-literally (doom-path straight-dir "build-cache.el"))
|
||||||
(let ((_ (read (current-buffer)))
|
(let ((_ (read (current-buffer)))
|
||||||
(last-emacs-version (read (current-buffer))))
|
(last-emacs-version (read (current-buffer))))
|
||||||
(user-error "Your version of Emacs has changed (from %S to %S). You must rebuild your packages with 'doom rebuild'."
|
(user-error "Your version of Emacs has changed (from %S to %S). You must rebuild your packages with 'doom rebuild -f'."
|
||||||
emacs-version last-emacs-version))))))
|
emacs-version last-emacs-version))))))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue