Subject: bug#78285: 31.0.50; load-prefer-newer causes recursive load on Windows

From: Eli Zaretskii <[email-masked]>
Date: Wed, 07 May 2025 14:27:32 +0300

> From: Gary Oberbrunner <[email-masked]>
> Date: Tue, 6 May 2025 18:04:22 -0400
> 
> Recent Emacs on Windows gets errors trying to recursively load during
> startup. I'm using prebuilt msix installer from kiennq
> (https://github.com/kiennq/emacs-build), and both the ucrt and regular versions show this bug. I have not
> built Emacs myself on Windows in a while, but the kiennq builds are usually solid.
> 
> Emacs -Q is OK, but this minimal setup shows the problem:
> 
> In $HOME/.config/emacs/init.el:
> 
>   (setq load-prefer-newer t)
> 
> Then start Emacs as usual. You will see startup taking a lot more time than
> usual, and then in *Messages* you'll see many errors like this one:
> 
> Error muted by safe_call: (apply native--compile-async (
>  "c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/emacs-lisp/cl-extra.el.gz"
> 
>   nil late))
>   signaled (error "Recursive load"
>   "c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/jka-compr.el.gz"
>   "c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/jka-compr.el.gz"
>   "c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/jka-compr.el.gz"
>   "c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/jka-compr.el.gz"
>   "c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/jka-compr.el.gz"
>   "c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/emacs-lisp/ring.el.gz"
> 
>   "c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/comint.elc"
>   "c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/progmodes/compile.elc")
> 
> 
> As you can see, these errors are suppressed in this test case, but in a real Emacs session,
> later on the same errors prevent loading various files, so my init.el
> never finishes loading. As an example of that, I get this error with my
> actual emacs config:
> 
> error: Recursive load, 
> c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/jka-compr.el.gz, 
> c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/jka-compr.el.gz, 
> c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/jka-compr.el.gz, 
> c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/jka-compr.el.gz, 
> c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/jka-compr.el.gz, 
> c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/emacs-lisp/radix-tree.el.gz,
> 
> c:/Program
> Files/WindowsApps/emacs-k_31.340.0.0_x64__tewns1xw2exn6/share/emacs/31.0.50/lisp/emacs-lisp/loaddefs-gen.elc,
> 
> c:/Users/garyo/.config/emacs/lisp/elpaca-bootstrap.el, 
> c:/Users/garyo/.config/emacs/init.el

As can be seen from the above, your configuration loads
elpaca-bootstrap.el, whose contents you haven''t shown.  Then Emacs
loads loaddefs-gen.elc, which wants to load radix-tree.elc, but
instead loads radix-tree.el.gz for some reason.

So there are several issues here that only you can investigate:

 . why does elpaca-bootstrap want to load loaddefs-gen at startup?
 . does Emacs load radix-tree.el.gz instead of radix-tree.elc? could
   it be that the time stamps in your installation tree are somehow
   messed up? on my systems, all the *.elc files in the installation
   tree are newer than the corresponding *.el.gz files, so setting
   load-prefer-newer non-nil doesn't cause any problems

Please look into these issues and sere what you find.

P.S. The prebuilt msix installer from kiennq is not something we
support here, so perhaps you should ask the persons who make that
distribution to help you.

Thanks.