doomemacs icon indicating copy to clipboard operation
doomemacs copied to clipboard

Doom CLI is not compiling `org-element.el`

Open LemonBreezes opened this issue 1 year ago • 3 comments

I confirm that...

  • [X] I have searched the issue tracker, documentation, FAQ, Discourse, and Google, in case this issue has already been reported/resolved.

  • [X] I have read "How to Debug Issues", and will use it to provide as much information about this issue as possible.

  • [X] The issue can be reproduced on the latest available commit of Doom.

  • [ ] The issue can be reproduced on a stable release of Emacs, such as 27, 28, or 29. (Unstable versions end in .50, .60, or .9x) (I have not tested)

When I install org and require org-element, I expect org-element-context to be byte or native-compiled. Changing the recipe to

(package! org
  :recipe (:host nil
           :repo "https://git.savannah.gnu.org/git/emacs/org-mode.git"
           :local-repo "org"
           :depth full
           :pre-build (straight-recipes-org-elpa--build)
           :build (:not autoloads)
           :files (:defaults "lisp/*.el" ("etc/styles/" "etc/styles/*"))))

makes no difference. Also, trying to reproduce this in emacs -Q with:

;; Bootstrap straight
(defvar bootstrap-version)

(let ((bootstrap-file
       (expand-file-name "straight/repos/straight.el/bootstrap.el" user-emacs-directory))
      (bootstrap-version 5))
  (unless (file-exists-p bootstrap-file)
    (with-current-buffer
        (url-retrieve-synchronously "https://raw.githubusercontent.com/raxod502/straight.el/develop/install.el"
                                    'silent 'inhibit-cookies)
      (goto-char (point-max))
      (eval-print-last-sexp)))
  (load bootstrap-file nil 'nomessage))

(straight-use-package 'org)

(require 'org-element)

does not reproduce the issue, i.e., org-element-context shows up as byte-compiled. Therefore, I believe this is an issue with the Doom CLI.

System Information

https://pastebin.com/xqt0ZD0m

LemonBreezes avatar Mar 05 '24 05:03 LemonBreezes

Testing that recipe, org-element.el and org-element-context are byte-compiled, so I've failed to reproduce it on 29.2 (without native-comp). It may be an Emacs HEAD issue, but I'll do more testing.

EDIT: Also unable to reproduce this on Emacs 30.0.50 w/ native-comp (https://github.com/emacs-mirror/emacs/commit/e02c4a864f02787f0e194c9e8a6d4ab0b18ca39f)

hlissner avatar Mar 05 '24 06:03 hlissner

For some reason, I recompiled Emacs and deleted all the build, straight and eln-cache folders, and everything seems to have compiled it this time. I have no idea what the issue is but there is something really spooky going on that sometimes I look and some files in say, Org, are not byte-compiled.

LemonBreezes avatar Mar 06 '24 19:03 LemonBreezes

I can confirm this, both on Emacs 29 and 30.0.50 (3cdd86b8affa6d58de8f6d07b4e117676fedd58c); MacOS, aarch64.

In my case e.g. Magit got byte-compiled only partially and Eat (installed through package!) wasn't getting byte-compiled at all.

Manually launching (byte-recompile-directory "~/.emacs.d/.local/straight/build-30.0.50" 0) "solved" the problem and the files are even getting correctly native-compiled then (during the runtime, as usual).

fwiw, my configuration is here, nothing fancy:

https://github.com/Patryk27/dotfiles/tree/main/apps/emacs/doom.d https://github.com/Patryk27/dotfiles/blob/main/apps/emacs.nix

I've been also testing with packages.el & config.el totally commented out, got the same behavior; nuking straight didn't help either.

Patryk27 avatar Apr 19 '24 16:04 Patryk27

I recently came across this issue with straight.el, which might explain this problem. Could one of you toss this into $DOOMDIR/init.el and let me know if it fixes your issue? You'll need to either run doom sync --rebuild to rebuild all packages or manually delete $EMACSDIR/.local/straight/repos/org before doom syncing.

(defadvice! doom-cli--straight-byte-compile-a (recipe)
  "See https://github.com/radian-software/straight.el/pull/1132"
  :override #'straight--build-compile
  (let* ((pkg (plist-get recipe :package))
         (dir (straight--build-dir pkg))
         (emacs (concat invocation-directory invocation-name))
         (buffer straight-byte-compilation-buffer)
         (deps
          (let (tmp)
            (dolist (dep (straight--flatten (straight-dependencies pkg)) tmp)
              (let ((build-dir (straight--build-dir dep)))
                (when (file-exists-p build-dir)
                  (push build-dir tmp))))))
         (print-circle nil)
         (print-length nil)
         (program
          (format "%S" `(let ((default-directory ,(straight--build-dir))
                              (lp load-path))
                          (setq load-path (list default-directory))
                          (normal-top-level-add-subdirs-to-load-path)
                          (setq load-path (append '(,dir) ',deps load-path lp))
                          (byte-recompile-directory ,dir 0 'force))))
         (args (list "-Q" "--batch" "--eval" program)))
    (when buffer
      (with-current-buffer (get-buffer-create buffer)
        (insert (format "\n$ %s %s \\\n %S\n" emacs
                        (string-join (butlast args) " ")
                        program))))
    (apply #'call-process `(,emacs nil ,buffer nil ,@args))))

hlissner avatar Jul 26 '24 00:07 hlissner

(I posted this in the wrong place. Sorry.)

hlissner avatar Jul 26 '24 04:07 hlissner

Hi, I was the reporter on Discord as well and can confirm that devadvice!-ing helps (in both eat and org-element's case) 🙂

(previously I've forked straight and overwritten it inside package.el, but advising is ofc. the simpler approach here)

Patryk27 avatar Jul 26 '24 07:07 Patryk27

Btw, your second answer seems to be mixed up 👀

@Patryk27 Ack. My bad.

Hi, I was the reporter on Discord as well and can confirm that devadvice!-ing helps (in both eat and org-element's case) 🙂

Good to hear. I'll go ahead with the advice then. Thanks for letting me know!

hlissner avatar Jul 26 '24 07:07 hlissner

As of 54a084f this should be resolved. Let me know if that isn't the case and I'll reopen it. Thanks for bringing it to my attention!

hlissner avatar Jul 26 '24 08:07 hlissner