Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

emacsPackages.tree-sitter-langs: Python grammar uses incompatible ABI version #209114

Open
mcwitt opened this issue Jan 4, 2023 · 3 comments
Open
Labels
0.kind: bug Something is broken 6.topic: emacs Text editor

Comments

@mcwitt
Copy link
Contributor

mcwitt commented Jan 4, 2023

Describe the bug

Trying to use elisp-tree-sitter in Python buffers fails with the following error:

Language’s ABI is too new: 14, (13 . 13), "/nix/store/y5yzbhx8k4c5svc86aq9mrmljqciijbj-emacs-tree-sitter-grammars/langs/bin/python.so"

Steps To Reproduce

Steps to reproduce the behavior:

nix-shell -I nixpkgs=. -p 'emacsWithPackages (ps: with ps; [ tree-sitter tree-sitter-langs ])' --run "emacs -Q"

Execute the elisp commands:

(require 'tree-sitter)
(require 'tree-sitter-langs)

Finally, open a Python buffer and do M-x tree-sitter-hl-mode to reproduce the above error.

Expected behavior

elisp-tree-sitter should work in Python buffers. (This issue does not occur with Haskell or Nix buffers, for example).

Additional context

The cause seems to be that the upstream https://github.com/tree-sitter/tree-sitter-python generated the parser using ABI version 14 (which is now the default, since tree-sitter/tree-sitter@e2fe380), but elisp-tree-sitter does not support this since it uses an older tree-sitter version.

I'm able to work around this with the following nixpkgs overlay:

final: prev:
{
  tree-sitter-grammars = prev.tree-sitter-grammars // {
    tree-sitter-python = prev.tree-sitter-grammars.tree-sitter-python.overrideAttrs (_: {
      nativeBuildInputs = [ final.nodejs final.tree-sitter ];
      configurePhase = ''
        tree-sitter generate --abi 13 src/grammar.json
      '';
    });
  };
}

Related issue: emacs-tree-sitter/elisp-tree-sitter#247

Notify maintainers

@pimeys , @adisbladis

Metadata

  • system: "x86_64-linux"
  • host os: Linux 5.15.85, NixOS, 22.11 (Raccoon), 22.11.20230103.a9eedea
  • multi-user?: yes
  • sandbox: yes
  • version: nix-env (Nix) 2.11.1
  • channels(matt): ""
  • channels(root): "nixos, nixpkgs"
  • nixpkgs: /nix/var/nix/profiles/per-user/root/channels/nixos
@mcwitt mcwitt added the 0.kind: bug Something is broken label Jan 4, 2023
@mcwitt mcwitt changed the title is:issue is:open emacsPackages.tree-sitter-langs: Python grammar uses incompatible ABI version emacsPackages.tree-sitter-langs: Python grammar uses incompatible ABI version Jan 4, 2023
@alyssais alyssais added the 6.topic: emacs Text editor label Feb 1, 2023
@clhodapp
Copy link
Contributor

clhodapp commented Jul 3, 2023

I'll raise that it seems like this comment is relevant to this situation: #230547 (comment)

@xinyifly
Copy link

xinyifly commented Jul 4, 2023

I think this can be solved more or less by installing emacs29 and using built-in treesit now.

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/tree-sitter-grammars-collide-with-each-other/41805/10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.kind: bug Something is broken 6.topic: emacs Text editor
Projects
None yet
Development

No branches or pull requests

5 participants