fix: doom/reload 404ing on executables

Half-reverts c2c6a64, which tried to get doom/reload to regenerate the
envvar file from within Emacs, but running an environment scraper in a
bare environment is really hard to get right. Ideally, your shell config
should set up your environment, but there are too many edge cases or
poor configs in the wild to depend on this.

I've brought back doom/reload-env, but only to reload the envvar file
-- *not* regenerate it. I've given up on trying to do that from within
Emacs.

Fix #5344
Ref c2c6a64118
This commit is contained in:
Henrik Lissner 2021-08-11 01:43:22 -04:00
parent 2c4328ccf0
commit 9687c04a84

View file

@ -76,21 +76,9 @@ Runs `doom-after-reload-hook' afterwards."
(interactive) (interactive)
(mapc #'require (cdr doom-incremental-packages)) (mapc #'require (cdr doom-incremental-packages))
(doom--if-compile (format "%S sync" doom-bin) (doom--if-compile (format "%S sync" doom-bin)
(let ((doom-reloading-p t)) (let ((doom-reloading-p t)
doom-env-file)
(doom-run-hooks 'doom-before-reload-hook) (doom-run-hooks 'doom-before-reload-hook)
(when (file-readable-p doom-env-file)
(if IS-WINDOWS
(message "Can't regenerate envvar file from within Emacs in Windows. Skipping...")
(let (process-environment)
(doom--if-compile
(format "%s -ic '%S env'"
(string-trim
(shell-command-to-string
(format "getent passwd %S | cut -d: -f7"
(user-login-name))))
doom-bin)
(message "Successfully regenerated envvar file")
(error "Failed to generate env file")))))
(doom-initialize 'force) (doom-initialize 'force)
(with-demoted-errors "PRIVATE CONFIG ERROR: %s" (with-demoted-errors "PRIVATE CONFIG ERROR: %s"
(general-auto-unbind-keys) (general-auto-unbind-keys)
@ -117,6 +105,19 @@ line."
(doom-initialize-packages) (doom-initialize-packages)
(doom-autoloads-reload)) (doom-autoloads-reload))
;;;###autoload
(defun doom/reload-env ()
"Reloads your envvar file.
DOES NOT REGENERATE IT. You must run 'doom env' in your shell OUTSIDE of Emacs.
Doing so from within Emacs will taint your shell environment.
An envvar file contains a snapshot of your shell environment, which can be
imported into Emacs."
(interactive "P")
(doom-load-envvars-file doom-env-file)
(message "Reloaded %S" (abbreviate-file-name doom-env-file)))
;;;###autoload ;;;###autoload
(defun doom/upgrade () (defun doom/upgrade ()
"Run 'doom upgrade' then prompt to restart Emacs." "Run 'doom upgrade' then prompt to restart Emacs."