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

tsc-lang-abi-too-new when installing new language #247

Open
leotrs opened this issue Dec 3, 2022 · 11 comments
Open

tsc-lang-abi-too-new when installing new language #247

leotrs opened this issue Dec 3, 2022 · 11 comments

Comments

@leotrs
Copy link

leotrs commented Dec 3, 2022

I have a tree-sitter parser that I'm trying to add to emacs-tree-sitter. However, when running (tree-sitter-require 'rsm), I get the following error ("rsm" is the name of my language):

Debugger entered--Lisp error: (tsc-lang-abi-too-new 14 (13 . 13) "/home/leo/.tree-sitter/bin/rsm.so")
  tsc--load-language("/home/leo/.tree-sitter/bin/rsm.so" "tree_sitter_rsm" rsm)
  (let ((language (tsc--load-language full-path native-symbol-name lang-symbol))) (let* ((key lang-symbol) (v language)) (condition-case nil (with-no-warnings (map-put! tree-sitter-languages key v nil)) (map-not-inplace (setq tree-sitter-languages (map-insert tree-sitter-languages key v)) v))) language)
  (let* ((lang-name (symbol-name lang-symbol)) (fallback-name (replace-regexp-in-string "-" "_" lang-name)) (native-symbol-name (or native-symbol-name (format "tree_sitter_%s" fallback-name))) (files (if file (list file) (cons lang-name (if (string= lang-name fallback-name) nil (list fallback-name))))) (full-path (seq-some #'(lambda (base-name) (locate-file base-name tree-sitter-load-path tree-sitter-load-suffixes)) files))) (if full-path nil (error "Cannot find shared library for language: %S" lang-symbol)) (let ((language (tsc--load-language full-path native-symbol-name lang-symbol))) (let* ((key lang-symbol) (v language)) (condition-case nil (with-no-warnings (map-put! tree-sitter-languages key v nil)) (map-not-inplace (setq tree-sitter-languages (map-insert tree-sitter-languages key v)) v))) language))
  tree-sitter-load(rsm nil nil)
  (or (alist-get lang-symbol tree-sitter-languages) (tree-sitter-load lang-symbol file native-symbol-name))
  tree-sitter-require(rsm)
  (progn (tree-sitter-require 'rsm))
  elisp--eval-last-sexp(t)
  eval-last-sexp(t)
  eval-print-last-sexp(nil)
  funcall-interactively(eval-print-last-sexp nil)
  command-execute(eval-print-last-sexp)

The only other mention of this error tsc-lang-abi-too-new is here. Following that comment, I downgraded tree-sitter-cli from 0.20 to 0.19.5, and that fixed the issue.

Is there any reason why emacs won't load parsers generated with cli-v0.20? Can we expect this to be solved in the next release? Thanks.

@sogaiu
Copy link
Contributor

sogaiu commented Dec 3, 2022

@leotrs
Copy link
Author

leotrs commented Dec 6, 2022

Thanks for the references.

As far as I can tell, one major change was moving some files from ~/.tree-sitter/ to ~/.config/tree-sitter/. Is this the main reason 0.20 is not yet supported?

@sogaiu
Copy link
Contributor

sogaiu commented Dec 6, 2022

I haven't wrapped my head around the details.

I suspect that @ubolonton and/or @ethan-leba (participants of emacs-tree-sitter/tree-sitter-langs#80) might know though.

@ethan-leba
Copy link

As far as I understand it, the issue is exactly what is says on the tin. In the commit tree-sitter/tree-sitter@eaf9b17 (v0.20.7), they make a breaking change to the ABI, bumping it to v14. However emacs-tree-sitter depends on tree-sitter v0.20.0, which only supports up to v13. Note that you can use the --abi flag to lower the ABI version to 13 without downgrading TS.

@leotrs
Copy link
Author

leotrs commented Dec 6, 2022

Note that you can use the --abi flag to lower the ABI version to 13 without downgrading TS.

Ooooh that's a good one!

@sogaiu
Copy link
Contributor

sogaiu commented Dec 6, 2022

TIL!

@leotrs
Copy link
Author

leotrs commented Dec 6, 2022

As far as I understand it, the issue is exactly what is says on the tin. In the commit tree-sitter/tree-sitter@eaf9b17 (v0.20.7), they make a breaking change to the ABI, bumping it to v14. However emacs-tree-sitter depends on tree-sitter v0.20.0, which only supports up to v13. Note that you can use the --abi flag to lower the ABI version to 13 without downgrading TS.

So is it just a matter of figuring out why emacs-tree-sitter depends on v0.20.0? I gather that the location of shared libraries is one such reason. Are there other known problems?

@ethan-leba
Copy link

I think the overarching issue here is that development has frozen on this project. Especially now that tree sitter is integrated into Emacs 29, there doesn't seem much of a reason to put any further work into this package.

@leotrs
Copy link
Author

leotrs commented Dec 6, 2022

Ah. Well that makes sense. Thanks for all the hard work!

@Nebucatnetzer
Copy link

Is there a variable where one can add the flag?

@snowman
Copy link

snowman commented Jun 16, 2023

Is there a variable where one can add the flag?

$ tree-sitter --version
tree-sitter 0.20.8

$ git clone https://github.com/casouri/tree-sitter-module
$ cd tree-sitter-module
# modify build.sh, add below lines after 'git clone "https://github.com/${org}/${repo}.git"', and comment out `rm -rf "${lang}"`
cd elisp
tree-sitter generate --abi 13 src/grammar.json
cd ..

# then run
$ ./build.sh elisp

You should modify tree-sitter-langs--init-major-mode-alist in tree-sitter-langs.el by add (emacs-lisp-mode . elisp) to support emacs lisp mode.

Copy dist/libtree-sitter-elisp.so to tree-sitter-langs/bin/elisp.so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants