Subject: Re: bug#62136: 30.0.50; byte-compiled init.el loads correctly, but native compiled init.eln loads incompletely

From: Eli Zaretskii <[email-masked]>
Date: Sun, 12 Mar 2023 09:24:41 +0200

> Date: Sun, 12 Mar 2023 00:06:07 -0500
> From:  "Mark A. Hershberger" via "Bug reports for GNU Emacs,
>  the Swiss army knife of text editors" <[email-masked]>
> 
> 
> For a while now, I've had to re-byte-compile init.el to get it to work
> correctly. Today, I tracked down the problem to an incorrectly compiled
> .eln file.
> 
> My init.el is probably over-large and takes 8s to load normally.  But
> once it loads normally, a native compilation copy is created in
> ~/.emacs.d/eln-cache and subsequent loads take only 3s.  Which would be
> great if it were working, but the loading is incomplete because things
> like the theme are not loaded.  Erasing the init-*.eln file under
> ~/.emacs.d/eln-cache allows emacs to load properly using the
> byte-compiled file.  Example run:
> 
>     $ find ~/.emacs.d/ -mtime -0.002 -ls
>     17171430      4 drwxr-xr-x  26 mah      mah          4096 Mar 11 22:22 ~/.emacs.d/
>     17566126      4 drwx------   2 mah      mah          4096 Mar 11 22:22 ~/.emacs.d/auto-save-list
>     19674336     36 drwxr-xr-x   2 mah      mah         36864 Mar 11 22:21 ~/.emacs.d/eln-cache/30.0.50-29d0097a
>     19693480     68 -rwxr-xr-x   1 mah      mah         66280 Mar 11 22:21 ~/.emacs.d/eln-cache/30.0.50-29d0097a/init-1f8fd1e4-78889c62.eln
>     17171381    168 -rw-r--r--   1 mah      mah        169284 Mar 11 22:22 ~/.emacs.d/ido.last
>     17174597      4 drwxr-xr-x   2 mah      mah          4096 Mar 11 22:21 ~/.emacs.d/transient
>     17174599      4 -rw-r--r--   1 mah      mah          2019 Mar 11 22:21 ~/.emacs.d/transient/history.el
>     17189836    168 -rw-r--r--   1 mah      mah        169284 Mar 11 22:21 ~/.emacs.d/ido.last~
>     17171265      4 drwxr-xr-x   4 mah      mah          4096 Mar 11 22:22 ~/.emacs.d/straight
>     17175288    548 -rw-r--r--   1 mah      mah        558574 Mar 11 22:22 ~/.emacs.d/straight/build-cache.el
>     $ rm ~/.emacs.d/eln-cache/30.0.50-29d0097a/init-1f8fd1e4-78889c62.eln
>     $ # emacs properly started
>     $ # exit emacs
>     $ find ~/.emacs.d/ -mtime -0.002 -ls
>     17171430      4 drwxr-xr-x  26 mah      mah          4096 Mar 11 22:23 ~/.emacs.d/
>     17566126      4 drwx------   2 mah      mah          4096 Mar 11 22:23 ~/.emacs.d/auto-save-list
>     19674336     36 drwxr-xr-x   2 mah      mah         36864 Mar 11 22:23 ~/.emacs.d/eln-cache/30.0.50-29d0097a
>     19692826     68 -rwxr-xr-x   1 mah      mah         66280 Mar 11 22:23 ~/.emacs.d/eln-cache/30.0.50-29d0097a/init-1f8fd1e4-78889c62.eln
>     17189836    168 -rw-r--r--   1 mah      mah        169284 Mar 11 22:23 ~/.emacs.d/ido.last
>     17174597      4 drwxr-xr-x   2 mah      mah          4096 Mar 11 22:23 ~/.emacs.d/transient
>     17174599      4 -rw-r--r--   1 mah      mah          2019 Mar 11 22:23 ~/.emacs.d/transient/history.el
>     17171381    168 -rw-r--r--   1 mah      mah        169284 Mar 11 22:22 ~/.emacs.d/ido.last~
>     17171265      4 drwxr-xr-x   4 mah      mah          4096 Mar 11 22:23 ~/.emacs.d/straight
>     17175288    548 -rw-r--r--   1 mah      mah        560242 Mar 11 22:23 ~/.emacs.d/straight/build-cache.el
>     $ # emacs started without proper execution
> 
> FWIW, the theme is loaded using use-package:
> 
>     (use-package spacemacs-common
>       :straight (:host github :repo "nashamri/spacemacs-theme")
>       :init
>       (mah/show-load-time "loading spacemacs")
>       (load-theme 'spacemacs-dark t)
>       (mah/show-load-time "done loading spacemacs")
>       :ensure t)
> 
> The mah/show-load-time messages do not show up in the *Messages* buffer
> when during loads of the .eln file.

Thank you for your report.

However, having read the description, I don't think I understand what
is the problem in your case.  You say some .eln file is compiled
incorrectly, but what are the symptoms of that incorrectness?  You say
"things like the theme are not loaded", but don't tell what exactly is
not loaded and don't show the evidence and symptoms of those parts
which don't load.

IOW, please be more specific about the problems and provide more
details about the actual problems you see.  Bonus points for posting a
recipe to reproduce the problem with the minimal init.el file (and any
other files that are absolutely necessary for reproduction).

It would be also beneficial to take unnecessary 3rd-party packages out
of the equation.  So if you can reproduce the problem without
Spacemacs, without 'straight', and without use-package, it will make
our job of investigating the problem easier.  Long story short: try to
make the scenario as simple and with as few actors as possible, and
then post a complete and detailed description of what goes wrong in
that scenario.

> I saw https://debbugs.gnu.org/cgi/bugreport.cgi?bug=43969 which has some
> similarities, but there is more missing thand just the spacemacs theme.
> This makes me think that it isn't just a matter of missing requires.

Do you see any relevant error messages in *Messages* or any warnings
in *Warnings* buffers?