Warn about reloading env from within Emacs on Windows

This commit is contained in:
Henrik Lissner 2019-12-15 21:53:26 -05:00
parent 0001947401
commit 760dcbb8ea
No known key found for this signature in database
GPG key ID: 5F6C0EA160557395
2 changed files with 10 additions and 4 deletions

View file

@ -74,7 +74,9 @@ reloads your package list, and lastly, reloads your private config.el.
Runs `doom-reload-hook' afterwards." Runs `doom-reload-hook' afterwards."
(interactive) (interactive)
(require 'core-cli) (require 'core-cli)
(doom--compile (format "%s refresh" doom-bin) (when (and IS-WINDOWS (file-exists-p doom-env-file))
(warn "Can't regenerate envvar file from within Emacs. Run 'doom env' from the console"))
(doom--compile (format "%s refresh -e" doom-bin)
:on-success :on-success
(let ((doom-reloading-p t)) (let ((doom-reloading-p t))
(doom-initialize 'force) (doom-initialize 'force)
@ -114,6 +116,8 @@ If passed the prefix ARG, clear the envvar file. Uses the same mechanism as
An envvar file contains a snapshot of your shell environment, which can be An envvar file contains a snapshot of your shell environment, which can be
imported into Emacs." imported into Emacs."
(interactive "P") (interactive "P")
(when IS-WINDOWS
(user-error "Cannot reload envvar file from within Emacs on Windows, run it from cmd.exe"))
(doom--compile (doom--compile
(format "%s -c '%s env%s'" shell-file-name doom-bin (if arg " -c" "")) (format "%s -c '%s env%s'" shell-file-name doom-bin (if arg " -c" ""))
:on-success :on-success

View file

@ -222,8 +222,9 @@ BODY will be run when this dispatcher is called."
(defcligroup! "Maintenance" (defcligroup! "Maintenance"
"For managing your config and packages" "For managing your config and packages"
(defcli! (refresh re sync) (defcli! (refresh re sync)
((if-necessary-p ["-n" "--if-necessary"] "Only regenerate autoloads files if necessary") ((if-necessary-p ["-n" "--if-necessary"] "Only regenerate autoloads files if necessary")
(prune-p ["-p" "--prune"] "Purge orphaned packages & regraft repos")) (inhibit-envvar-p ["-e"] "Don't regenerate the envvar file")
(prune-p ["-p" "--prune"] "Purge orphaned packages & regraft repos"))
"Ensure Doom is properly set up. "Ensure Doom is properly set up.
This is the equivalent of running autoremove, install, autoloads, then This is the equivalent of running autoremove, install, autoloads, then
@ -241,7 +242,8 @@ stale."
(print! (start "Initiating a refresh of Doom Emacs...")) (print! (start "Initiating a refresh of Doom Emacs..."))
(print-group! (print-group!
(let (success) (let (success)
(when (file-exists-p doom-env-file) (when (and (not inhibit-envvar-p)
(file-exists-p doom-env-file))
(doom-cli-reload-env-file 'force)) (doom-cli-reload-env-file 'force))
;; Ensures that no pre-existing state pollutes the generation of the new ;; Ensures that no pre-existing state pollutes the generation of the new