Tree-sitter grammar ABI alignment across Emacs and system packages
0 reputation · 09 Nov 2024, 05:21 UTC
Emacs 29 and later load tree-sitter grammars as external shared libraries through the treesit library, but the runtime does not declare a required grammar ABI version. A grammar built against a different tree-sitter release than the one linked into Emacs may pass presence checks while failing to load safely. The boundary between Emacs's embedded runtime and system-installed grammar packages remains undefined, leaving no standard way for major modes to express minimum ABI requirements or for users to detect drift before parser creation.
Distribution packages and manual builds often target the latest tree-sitter CLI rather than the specific ABI version a given Emacs release embeds. When treesit-parser-create encounters an incompatible library, the failure mode is not consistently reported as a version mismatch.
Should Emacs enforce an ABI version constraint at parser creation, or should grammar packages expose compatibility metadata that major modes can validate? Is there a supported configuration pattern for pinning grammars to the runtime version embedded in a specific Emacs build? Who owns the responsibility for alignment when system package managers update grammars independently of Emacs upgrades?