Subject: bug#66534: 30.0.50; [PATCH] Expand file-name of ~/.emacs before attempt to load it

From: Eli Zaretskii <[email-masked]>
Date: Sat, 14 Oct 2023 09:54:00 +0300

> Date: Fri, 13 Oct 2023 20:41:16 +0200
> From:  Christoph via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> I noticed that during startup, emacs tries to load ~/.emacs (with
> different extensions) many times over.  You can see this by using
> strace and tracing the openat syscall.  The problem is, that `load'
> does not expand the ~/ in the filename passed to it.  So it does not
> recognize the file as being absolute and tries to resolve it using
> the load-path.
> 
> While resolving the path in the openp function in lread.c,
> `expand-file-name' is used with the default directory being the
> elements of the load-path.  Since for `expand-file-name', ~/.emacs is
> an absolute path, it returns the path unchanged, and load tries to
> load ~/.emacs many times over.

I don't understand what you are saying here.  The last sentence is
incorrect, as evidenced by the following:

  (expand-file-name "~/.emacs" "/tmp")
   => "/home/eliz/.emacs"

IOW, "~/.emacs" is indeed treated by Emacs as an absolute file name,
but expand-file-name does NOT return "~/.emacs" unchanged.

So please explain what exactly is the problem you see here, and in
particular what issues that problem causes in your case.

Thanks.