Hi, The reproducer using Emacs 28.2 and Org 9.6.1 both from Guix (29efa27):
--8<---------------cut here---------------start------------->8--- $ cd /tmp/ $ cat config.el (setq org-directory "/tmp/" org-agenda-files '("example.org")) $ cat example.org * TODO Stuff $ emacs -q -l config.el -f org-agenda Press m Match a TAGS/PROP/TODO query Error: org-get-buffer-tags: Symbol's function definition is void: org-element--cache-active-p $ emacs -q -l config.el --eval '(org-batch-agenda "m")' --batch Debugger entered--Lisp error: (void-function org-element--cache-active-p) org-element--cache-active-p() org-get-buffer-tags() org-make-tags-matcher(nil) org-tags-view(nil) funcall-interactively(org-tags-view nil) call-interactively(org-tags-view) org-agenda(nil "m") #f(compiled-function () #<bytecode 0xa6570c2f762a95a>)() funcall(#f(compiled-function () #<bytecode 0xa6570c2f762a95a>)) (let nil (funcall '#f(compiled-function () #<bytecode 0xa6570c2f762a95a>))) eval((let nil (funcall '#f(compiled-function () #<bytecode 0xa6570c2f762a95a>)))) org--batch-agenda("m" nil nil) (org-batch-agenda "m") command-line-1(("-l" "config.el" "--eval" "(org-batch-agenda \"m\")")) command-line() normal-top-level() --8<---------------cut here---------------end--------------->8--- To be precise, it is run inside a Linux namespace container: guix shell --container emacs emacs-org -E TERM \ -- emacs -q -l config.el -f org-agenda This message [1] about a similar topic leads to this commit 791ea50528df55bac110fe5e2731af056989bedb [2]: --8<---------------cut here---------------start------------->8--- * lisp/org-element.el (org-element--cache-active-p): Fix compiler warning Using `defsubst' here is impractical because some code above does call `org-element--cache-active-p'. Moving would trigger major refactoring for little gain. Hence, move back to using simple `defun' until we modularize lisp/org-element.el better. Reported-by: No Wayman <iarchivedmywholel...@gmail.com> Link: https://orgmode.org/list/874jws2v87....@gmail.com --8<---------------cut here---------------end--------------->8--- and I guess it is related. Especially with release note 9.6 [3]: Element cache is enabled by default and work for headings Obviously, loading org-element fixes the issue: $ emacs -q -l config.el --eval "(require 'org-element)" -f org-agenda Therefore, maybe the addition of such requirement in org-agenda.el could be enough? 1: [BUG] org-element: defsubst org-element--cache-active-p used before defined Tue, 27 Sep 2022 20:32:36 -0400 id:874jws2v87....@gmail.com 2: https://git.savannah.gnu.org/cgit/emacs/org-mode.git/commit/?id=791ea50528df55bac110fe5e2731af056989bedb 3: <https://orgmode.org/Changes.html> Cheers, simon