fix(cli): inability to find user-emacs-directory

user-emacs-directory is nil in batch sessions, which early-init.el
wasn't expecting, which caused bin/doom to refuse to run out of a
non-standard location.

Fix: #6777
This commit is contained in:
Henrik Lissner 2022-09-16 17:00:37 +02:00
parent c5e88d229f
commit 108158876c
No known key found for this signature in database
GPG key ID: B60957CA074D39A3

View file

@ -44,6 +44,12 @@
;; PERF: `file-name-handler-alist' is consulted often. Unsetting it offers a ;; PERF: `file-name-handler-alist' is consulted often. Unsetting it offers a
;; notable saving in startup time. ;; notable saving in startup time.
(let (file-name-handler-alist) (let (file-name-handler-alist)
;; FIX: If this file was loaded via -batch or bin/doom, then
;; `user-emacs-directory' won't be set. As a starting point, let's assume
;; it's the directory this early-init.el file lives in.
(unless user-emacs-directory
(setq user-emacs-directory (file-name-directory (file-truename load-file-name))))
;; FEAT: First, we process --init-directory and --profile to detect what ;; FEAT: First, we process --init-directory and --profile to detect what
;; `user-emacs-directory' to load from. I avoid using ;; `user-emacs-directory' to load from. I avoid using
;; `command-switch-alist' to process --profile and --init-directory because ;; `command-switch-alist' to process --profile and --init-directory because