Subject: bug#59795: 30.0.50; locate-user-emacs-file refer to relative path with --init-directory is passed as relative path

From: Eli Zaretskii <[email-masked]>
Date: Sat, 03 Dec 2022 14:12:50 +0200

> Date: Sat, 03 Dec 2022 11:31:59 +0000
> From: Tommaso Rossi <[email-masked]>
> Cc: [email-masked]
> 
> Thanks for your reply.
> I think I didn't explained the problem very well, sorry for my english.

You have nothing to apologize about, I understood you completely.

> It is right that the init directory is interpreted relative to the 
> directory where Emacs is started, what feels a bit strange is that
> when you change directory inside Emacs, the init directory becomes 
> relative to the current directory for the function 
> locate-user-emacs-file.  I realized that when I found folders 
> named as my init directory spawned everywhere in my filesystem, for
> example containing Transient (Magit) history or other files that should 
> be in the real init directory.
> 
> In Emacs Lisp code, it becomes difficult to locate the real init 
> directory, because the user-emacs-directory is not absolute: if some 
> library or package uses the locate-user-emacs-file function, like 
> Transient, than this "init directory spawned everywhere" problem will 
> raise.

The latest code should produce an absolute file name in
user-emacs-directory, which I believe fixes the problem you described.  My
response just explained how will Emacs produce an absolute file name from a
relative one when it processes the --init-directory= option.

The fix is in the emacs-29 branch, soon to be merged to master, so you can
try the fix if you want.