" Cannot activate tree-sitter, because language grammar for tsx is unavailable "

What happened?

I’d like to try tree sitter for typescript/react development. I saw in this post that I should add the tree-sitter module in init.el and add flags to the lang modules I want, but when I try activating tsx-ts-mode I get the following error, depending on file:

:no_entry: Warning (treesit): Cannot activate tree-sitter, because language grammar for typescript is unavailable (not-found): (libtree-sitter-typescript.so libtree-sitter-typescript.so.0 libtree-sitter-typescript.so.0.0 libtree-sitter-typescript.dylib libtree-sitter-typescript.dylib.0 libtree-sitter-typescript.dylib.0.0) No such file or directory

:no_entry: Warning (treesit): Cannot activate tree-sitter, because language grammar for tsx is unavailable (not-found): (libtree-sitter-tsx.so libtree-sitter-tsx.so.0 libtree-sitter-tsx.so.0.0 libtree-sitter-tsx.dylib libtree-sitter-tsx.dylib.0 libtree-sitter-tsx.dylib.0.0) No such file or directory

When I try to activate tree-sitter-mode, I see `tree-sitter–setup: No language registered for major mode ‘tsx-ts-mode’. The file that I’m in has little to no syntax highlighting.

I ran tree-sitter-langs-install-grammars, and see tsx.dylib and typescript.dylib in .emacs.d/.local/straight/build-29.1/tree-sitter-langs/bin/.

What did you expect to happen?

I’m hoping to get syntax highlighting and general typescript/tsx support. I’ve been relying on typescript-tsx-mode for the last year or so and would love to leave it behind.

Side note: I’ve been using doom happily for about a year, but am still a beginner when it comes to understanding emacs internals. What’s the difference between typescript-tsx-mode vs ts-tsx-mode vs typescript-ts-mode? Should I be using one over the other? How does tree-sitter interact with everything?

Steps to reproduce

  1. Uncomment tree-sitter in init.el
  2. Add +tree-sitter to the web lang. (I now have: (web +lsp +tree-sitter))
  3. doom sync and restart emacs.

System information


Loading data dump...
1 Like

I have the same problem but on a Linux with emacs 29.2.

Warning (treesit): Cannot activate tree-sitter, because language grammar for json is unavailable (not-found): (libtree-sitter-json libtree-sitter-json.0 libtree-sitter-json.0.0 libtree-sitter-json.so libtree-sitter-json.so.0 libtree-sitter-json.so.0.0) No such file or directory

Grammar files are present, but without libtree-sitter- prefix:

$ ls .local/straight/build-29.2/tree-sitter-langs/bin/jso*
.local/straight/build-29.2/tree-sitter-langs/bin/json.so
.local/straight/build-29.2/tree-sitter-langs/bin/jsonnet.so

System information

generated  Feb 18, 2024 09:47:43
system     "Void Linux" Linux 6.6.16_1 x86_64 pgtk
emacs      29.2 EMACSDIR=~/.config/emacs/ EMACS=/usr/bin/emacs
doom       3.0.0-pre PROFILE=_@0 HEAD -> master f0ad16164 2024-02-17 07:13:39 -0500
           ~/.config/doom/
shell      /bin/bash
features   ACL CAIRO DBUS FREETYPE GIF GLIB GMP GNUTLS GSETTINGS HARFBUZZ JPEG JSON
           LCMS2 LIBOTF LIBXML2 MODULES NATIVE_COMP NOTIFY INOTIFY PDUMPER PGTK PNG
           RSVG SECCOMP SOUND SQLITE3 THREADS TIFF TOOLKIT_SCROLL_BARS TREE_SITTER
           WEBP XIM GTK3 ZLIB
traits     gui server-running envvar-file custom-file
custom     magit-todos-insert-after custom-safe-themes connection-local-profile-alist
           connection-local-criteria-alist
modules    :config use-package :completion company vertico :ui doom doom-dashboard
           doom-quit hl-todo modeline ophints (popup +defaults) tabs treemacs
           (vc-gutter +pretty) vi-tilde-fringe (window-select +numbers) workspaces
           :editor file-templates fold format multiple-cursors snippets :emacs dired
           electric undo vc :term eshell vterm :checkers syntax (spell +everywhere)
           :tools editorconfig (eval +overlay) lookup lsp magit pdf tmux tree-sitter
           :lang (cc +lsp +tree-sitter) (common-lisp +tree-sitter) (emacs-lisp
           +tree-sitter) (json +tree-sitter) (markdown +grip +tree-sitter) (org +roam2
           +tree-sitter) (python +lsp +tree-sitter) (sh +lsp +tree-sitter) :config
           (default +bindings +smartparens)