Ray's Knowledge Base
Unlock

On Emacs 31, Marginalia can call compat--seconds-to-string before Compat defines it

PitfallVerified 6 Oct 2026Holds anywhere
Pitfall. The symptom, what causes it, and the fix that was run and seen to work.

Symptom#

consult-buffer shows Vertico detected an error: ... (void-function compat--seconds-to-string).

Cause#

Marginalia uses the internal Compat helper compat--seconds-to-string for relative file-age annotations. On Emacs 31, loading compat alone can leave it undefined.

Fix#

Do not debug native-compilation variables. Load the compiled compat-31.elc when the helper is missing, from the directory of compat-31:

(unless (fboundp 'compat--seconds-to-string)
  (load (expand-file-name "compat-31.elc"
          (file-name-directory (locate-library "compat-31")))))

Put this in the tracked init.el before the modules load. A file that is not tracked or not loaded at startup does not fix a fresh start, so check startup wiring after emacs-restart, not only the live session.

Evidence#

Reported in a session on Emacs 31. The snippet is not shown running in the note.

Also found by searching

  • Vertico detected an error: Symbol's function definition is void: compat--seconds-to-string
  • consult-buffer fails with void-function compat--seconds-to-string on Emacs 31
  • marginalia compat missing function Emacs 31
  • how to load compat-31 for marginalia