After updating to emacs version 30.1 from version 29.4.4, I experience issues
with =org-element-with-disabled-cache=. Specifically, creating an =org-roam=
node with a template that sets a =#+category= yields the error
=invalid-function org-element-with-disabled-cache=. Here is a MWE you save to
=mwe.el= and run with =emacs -q -l mwe.el=:
#+BEGIN_SRC emacs-lisp
;; Workaround after removing natively compiled org-element file ;;
; (setq native-comp-jit-compilation-deny-list '(".*org-element.*"))
;; download org-roam ;;
(require 'package)
(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t)
(package-initialize)
(package-refresh-contents)
(package-install 'org-roam)
;; Define a capture-template containing a #+category ;;
(setq org-roam-capture-templates '(("e" "Example Template" plain "%?"
:if-new (file+head "${title} (vom
%<%d.%m.%Y>).org"
"#+title:
${title}\n#+category: Example Category\n")
:unnarrowed t)))
#+END_SRC
Just call =org-roam-node-find= interactively, type in a node name and press
=RET= to provoke the error; I reproduced it on two different machines. Here is
the output of =toggle-debug-on-error=:
#+BEGIN_SRC lisp
Debugger entered--Lisp error: (invalid-function
org-element-with-disabled-cache)
org-element-with-disabled-cache((keyword (:standard-properties [26 26 nil nil
55 0 nil nil element t nil nil nil nil #<buffer An Example Node (vom
06.03.2025).org> nil nil (section (:standard-properties [1 1 1 55 55 0 nil
first-section element t nil 1 55 nil #<buffer An Example Node (vom
06.03.2025).org> nil nil (org-data ...)]))] :key "CATEGORY" :value "Example
Category")))
org-element--get-category()
org-element--get-global-node-properties((org-data (:standard-properties [1 1
1 55 55 0 nil org-data nil t nil 3 55 nil #<buffer An Example Node (vom
06.03.2025).org> [org-element-deferred org-element--get-global-node-properties
nil t] nil nil] :path "<path>/An Example Node (vom 06.03.2025).org")))
apply(org-element--get-global-node-properties (org-data (:standard-properties
[1 1 1 55 55 0 nil org-data nil t nil 3 55 nil #<buffer An Example Node (vom
06.03.2025).org> [org-element-deferred org-element--get-global-node-properties
nil t] nil nil] :path "<path>/An Example Node (vom 06.03.2025).org")) nil)
org-element--property(:deferred (org-data (:standard-properties [1 1 1 55 55
0 nil org-data nil t nil 3 55 nil #<buffer An Example Node (vom
06.03.2025).org> [org-element-deferred org-element--get-global-node-properties
nil t] nil nil] :path "<path>/An Example Node (vom 06.03.2025).org")) nil
force-undefer)
org-element--property(:ID (org-data (:standard-properties [1 1 1 55 55 0 nil
org-data nil t nil 3 55 nil #<buffer An Example Node (vom 06.03.2025).org>
[org-element-deferred org-element--get-global-node-properties nil t] nil nil]
:path "<path>/An Example Node (vom 06.03.2025).org")) nil nil)
org--property-local-values("ID" nil 1)
org-entry-get(1 "ID")
org-roam-capture--setup-target-location()
org-roam-capture--prepare-buffer()
org-capture-set-target-location(nil)
org-capture(nil "e")
org-roam-capture-(:node #s(org-roam-node :file nil :file-title nil :file-hash
nil :file-atime nil :file-mtime nil :id "20250306T144538.658754" :level nil
:point nil :todo nil :priority nil :scheduled nil :deadline nil :title "An
Example Node" :properties nil :olp nil :tags nil :aliases nil :refs nil)
:templates nil :props (:finalize find-file :call-location #<marker at 218 in
*scratch*>))
org-roam-node-find()
funcall-interactively(org-roam-node-find)
command-execute(org-roam-node-find)
#+END_SRC
It is clear that the problem stems from =org-element--get-category= and not
from an =org-roam= function. What I found in a
[[https://www.reddit.com/r/emacs/comments/1hayavx/comment/mg4ioph/?context=3][Reddit
Post]] is that the problem stems from natively compiling the library
=org-element=. The current workaround is this:
1. Prevent =org-element= from being natively compiled again by adding the line
=(setq native-comp-jit-compilation-deny-list '(".*org-element.*"))= to the very
top of your init file.
2. For every directory specified in =native-comp-eln-load-path= (=C-h v= on
that to see what it contains), delete any previously natively compiled file for
=org-element= by doing the following:
1. =cd= into the directory then =ls */org-element-*.eln=
2. If you see a file =org-element-<hash>.eln=, delete it. (The file
=org-element-ast-<hash>.eln= does not seem to cause any problems.)
3. Restart emacs and emacsclient.
In addition to the =#+category= problem, a
[[https://www.reddit.com/r/emacs/comments/1hayavx/comment/mg4ioph/?context=3][Reddit
user]] reports that clocking in/out, using the agenda or changing TODO states
results in the same error. I could not reproduce this, though.
I am aware this is just a minor bug, but I found it worthy of being reported.
Maybe someone familiar with native compilation would be willing to look into
this?