Subject: bug#72294: 29.2; Emacs --init-directory=... puts user-init-file elsewhere

From: Eli Zaretskii <[email-masked]>
Date: Thu, 25 Jul 2024 21:56:15 +0300

> From: Sean Devlin <[email-masked]>
> Date: Thu, 25 Jul 2024 12:12:07 -0400
> 
> 1. emacs --init-directory=/tmp/emacs
> 2. M-: user-init-file RET
> 
> The user-init-file is ~/.emacs, despite the flag to use /tmp/emacs as
> the init directory.
> 
> Maybe this is intended behavior, but I found it confusing. The manual
> says this about the flag:
> 
> "Specify the directory to use when looking for the Emacs init files."
> 
> I interpreted this to mean all init files, including the user-init-file.

That option sets user-emacs-directory, it doesn't directly affect
user-init-file.

Emacs by default sets user-emacs-directory to the directory where it
actually finds the init file.  This option overrides that.

> A workaround is to create /tmp/emacs/init.el before starting Emacs:
> 
> 1. mkdir -p /tmp/emacs
> 2. touch /tmp/emacs/init.el
> 3. emacs --init-directory=/tmp/emacs

It isn't a workaround, it's how you should do it.

I don't think this is a bug.  The search for init file and the setting
of user-emacs-directory that follows are complex issues, not easily
explained in a few words.

May I ask why you needed to use this option?  It should not be
generally needed.