From ceae154751b76734ee029074cb8c37738b090d43 Mon Sep 17 00:00:00 2001 From: Henrik Lissner Date: Wed, 7 Sep 2022 16:43:00 +0200 Subject: [PATCH] fix(cli): reading dir perms on a non-existent dir This is a regression from c05e615. doom.el changes user-emacs-directory to doom-cache-dir, which may not exist yet, at the time of this check, causing file-attributes to return nil, and causing = to throw a type error (see #6754). In addition to fixing this, I've also made the check more liberal about failures, in the odd case that doom-emacs-dir, too, does not exist at the time bin/doom is called (it'd be very hard to pull that off, but not impossible). Fix: #6754 Amend: c05e61536ed9 --- bin/doom | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/doom b/bin/doom index 473b05be2..50086ce58 100755 --- a/bin/doom +++ b/bin/doom @@ -88,8 +88,8 @@ ;; UX: Abort if the user is using 'doom' as root, unless ~/.emacs.d is owned by ;; root, in which case we assume the user genuinely wants root to be their ;; primary user account for Emacs. -(when (equal (user-real-uid) 0) - (unless (= 0 (file-attribute-user-id (file-attributes user-emacs-directory))) +(when (equal 0 (user-real-uid)) + (unless (equal 0 (file-attribute-user-id (file-attributes doom-emacs-dir))) (message (concat "Error: this script was executed as root, which is likely not what you want.\n" @@ -98,7 +98,7 @@ "If this really *is* what you want, then change the owner of your Emacs\n" "config to root:\n\n" ;; TODO Add cmd.exe/powershell commands - " chown root:root -R " (abbreviate-file-name user-emacs-directory) "\n\n" + " chown root:root -R " (abbreviate-file-name doom-emacs-dir) "\n\n" "Aborting...")) (kill-emacs 2)))