Subject: Re: bug#25163: 26.0.50; Unable to access `user-emacs-directory' (~/.emacs.d/)

From: [email-masked]
Date: Sat, 10 Dec 2016 23:24:06 -0500

Richard Kim <[email-masked]> writes:

> My build of emacs 26 (git repo version 25a52ca of 2016/12/10)
> starts up with the following warning:
>
>   Warning (initialization): Unable to access `user-emacs-directory' (~/.emacs.d/).
>   Any data that would normally be written there may be lost!
>   If you never want to see this message again,
>   customize the variable `user-emacs-directory-warning'.
>
> This is despite setting the variable as suggested to suppress such warning.
> I think this warning should not be printed.
>
> Emacs is started like this:
>
>   chmod 0 ~/.emacs.d
>   ~/opt/emacs26/bin/emacs -q \
>     --eval '(setq user-emacs-directory (expand-file-name "~/elisp/"))' \
>     --eval '(setq user-emacs-directory-warning nil)'
>
> Emacs 25 (git repo build of emacs-25 branch) started the same way does
> not print this warning.

I see the same in Emacs 25, 24.5, and 24.4; 24.3 just prints a "File
exists" message.  Looks like the problem is that locate-user-emacs-file
(and thus the check for the warning) is called before any customizations
(or --eval args) are executed.  Here's a backtrace I got by putting
(debug) inside locate-user-emacs-file, just before the `display-warning'
call:

Debugger entered: nil
  locate-user-emacs-file("abbrev_defs" ".abbrev_defs")
  #[0 "\300\301\302\"\207" [locate-user-emacs-file "abbrev_defs" ".abbrev_defs"] 3]()
  funcall(#[0 "\300\301\302\"\207" [locate-user-emacs-file "abbrev_defs" ".abbrev_defs"] 3])
  eval((funcall (function #[0 "\300\301\302\"\207" [locate-user-emacs-file "abbrev_defs" ".abbrev_defs"] 3])))
  custom-reevaluate-setting(abbrev-file-name)
  mapc(custom-reevaluate-setting (temporary-file-directory transient-mark-mode small-temporary-file-directory auto-save-file-name-transforms remote-shell-program Info-default-directory-list rmail-spool-directory abbrev-file-name auto-encryption-mode blink-cursor-mode tutorial-directory global-font-lock-mode file-name-shadow-mode query-replace-from-to-separator image-load-path mouse-wheel-mode electric-indent-mode electric-quote-mode global-eldoc-mode tooltip-mode))
  command-line()
  normal-top-level()

Perhaps the warning could be delayed until after init time?