fix(lib): doom/{reload,upgrade}: expand path to bin/doom

A user's shell config might destructively alter the shell's $PATH (also
common on MacOS, which destructively sets $PATH with its system dotfiles
for ZSH). This prevents the sub-shell spawned from `doom/reload` and
`doom/upgrade` from inheriting emacs' `$PATH`, which Doom adds
$EMACSDIR/bin to. Without this entry, these commands would fail to find
the Doom script.

Fix: #8027
Amend: a8ba8feecb
This commit is contained in:
Henrik Lissner 2024-08-27 03:19:57 -04:00
parent 1430e9c700
commit a5039c4333
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -56,7 +56,7 @@ And jumps to your `doom!' block."
(defmacro doom--if-compile (command on-success &optional on-failure) (defmacro doom--if-compile (command on-success &optional on-failure)
(declare (indent 2)) (declare (indent 2))
`(let ((default-directory doom-emacs-dir) `(let ((default-directory doom-emacs-dir)
(exec-path (cons doom-bin-dir exec-path))) (doom-bin (expand-file-name "doom" doom-bin-dir)))
;; Ensure the bin/doom operates with the same environment as this ;; Ensure the bin/doom operates with the same environment as this
;; running session. ;; running session.
(letenv! (("EMACS" (doom-path invocation-directory invocation-name)) (letenv! (("EMACS" (doom-path invocation-directory invocation-name))
@ -64,7 +64,7 @@ And jumps to your `doom!' block."
("DOOMDIR" doom-user-dir) ("DOOMDIR" doom-user-dir)
("DOOMLOCALDIR" doom-local-dir) ("DOOMLOCALDIR" doom-local-dir)
("DEBUG" (and doom-debug-mode "1"))) ("DEBUG" (and doom-debug-mode "1")))
(with-current-buffer (compile ,command t) (with-current-buffer (compile (format ,command doom-bin) t)
(let ((w (get-buffer-window (current-buffer)))) (let ((w (get-buffer-window (current-buffer))))
(select-window w) (select-window w)
(add-hook (add-hook
@ -77,7 +77,7 @@ And jumps to your `doom!' block."
,on-failure)) ,on-failure))
nil 'local)))))) nil 'local))))))
(defvar doom-reload-command "doom sync -B -e" (defvar doom-reload-command "%s sync -B -e"
"Command that `doom/reload' runs.") "Command that `doom/reload' runs.")
;;;###autoload ;;;###autoload
(defun doom/reload () (defun doom/reload ()
@ -141,7 +141,7 @@ imported into Emacs."
(doom-load-envvars-file doom-env-file) (doom-load-envvars-file doom-env-file)
(message "Reloaded %S" (abbreviate-file-name doom-env-file)))))) (message "Reloaded %S" (abbreviate-file-name doom-env-file))))))
(defvar doom-upgrade-command "doom upgrade -B --force" (defvar doom-upgrade-command "%s upgrade -B --force"
"Command that `doom/upgrade' runs.") "Command that `doom/upgrade' runs.")
;;;###autoload ;;;###autoload
(defun doom/upgrade () (defun doom/upgrade ()