nvim-treesitter / nvim-treesitter

Nvim Treesitter configurations and abstraction layer
Apache License 2.0
10.83k stars 900 forks source link

TS Update fails on Mac. #2335

Closed nabezokodaikon closed 2 years ago

nabezokodaikon commented 2 years ago

Describe the bug

Occurs when treesitter is installed without treesitter installed. スクリーンショット 2022-01-23 4 59 56

スクリーンショット 2022-01-23 5 09 51

To Reproduce

  1. Run TSUpdate

Expected behavior

All installations complete successfully without any errors.

Output of :checkhealth nvim-treesitter

nvim: health#nvim#check
========================================================================
## Configuration
  - OK: no issues found

## Performance
  - OK: Build type: Release

## Remote Plugins
  - OK: Up to date

## terminal
  - INFO: key_backspace (kbs) terminfo entry: key_backspace=^H
  - INFO: key_dc (kdch1) terminfo entry: key_dc=\E[3~
  - INFO: $TERM_PROGRAM='tmux'
  - INFO: $COLORTERM='truecolor'

## tmux
  - OK: escape-time: 0
  - INFO: Checking stuff
  - OK: focus-events: on
  - INFO: $TERM: screen-256color

nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
  - OK: `tree-sitter` found  0.20.3 (parser generator, only needed for :TSInstallFromGrammar)
  - OK: `node` found v17.4.0 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `gcc` executable found. Selected from { "gcc" }
    Version: Configured with: --prefix=/Library/Developer/CommandLineTools/usr --with-gxx-include-dir=/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/4.2.1
  - OK: Neovim was compiled with tree-sitter runtime ABI version 14 (required >=13). Parsers must be compatible with runtime ABI.

## Parser/Features H L F I J
  - glsl           ✓ ✓ ✓ ✓ ✓ 
  - comment        ✓ . . . . 
  - vue            ✓ . ✓ ✓ ✓ 
  - vim            ✓ ✓ . . ✓ 
  - fusion         ✓ ✓ ✓ ✓ . 
  - gdscript       ✓ ✓ . . ✓ 
  - ledger         ✓ . ✓ ✓ ✓ 
  - rust           ✓ ✓ ✓ ✓ ✓ 
  - java           ✓ ✓ . ✓ ✓ 
  - turtle         ✓ ✓ ✓ ✓ ✓ 
  - python         ✓ ✓ ✓ ✓ ✓ 
  - c              ✓ ✓ ✓ ✓ ✓ 
  - javascript     ✓ ✓ ✓ ✓ ✓ 
  - julia          ✓ ✓ ✓ ✓ ✓ 
  - kotlin         ✓ ✓ ✓ . ✓ 
  - rst            ✓ ✓ . . ✓ 
  - hjson          ✓ ✓ ✓ ✓ ✓ 
  - hocon          ✓ . . . ✓ 
  - llvm           ✓ . . . . 
  - sparql         ✓ ✓ ✓ ✓ ✓ 
  - jsonc          ✓ ✓ ✓ ✓ ✓ 
  - http           ✓ . . . ✓ 
  - clojure        ✓ ✓ ✓ . ✓ 
  - prisma         ✓ . . . . 
  - rasi           ✓ ✓ ✓ ✓ . 
  - cpp            ✓ ✓ ✓ ✓ ✓ 
  - dart           ✓ ✓ . ✓ ✓ 
  - typescript     ✓ ✓ ✓ ✓ ✓ 
  - dot            ✓ . . . ✓ 
  - heex           ✓ . ✓ ✓ ✓ 
  - ocaml_interface✓ ✓ ✓ . ✓ 
  - bash           ✓ ✓ ✓ . ✓ 
  - cmake          ✓ . ✓ . . 
  - cuda           ✓ ✓ ✓ ✓ ✓ 
  - zig            ✓ . ✓ ✓ ✓ 
  - css            ✓ . ✓ ✓ ✓ 
  - yaml           ✓ ✓ ✓ ✓ ✓ 
  - nix            ✓ ✓ ✓ . ✓ 
  - regex          ✓ . . . . 
  - scss           ✓ . . ✓ . 
  - graphql        ✓ . . ✓ ✓ 
  - pioasm         ✓ . . . ✓ 
  - json5          ✓ . . . ✓ 
  - hcl            ✓ . ✓ ✓ ✓ 
  - erlang         . . . . . 
  - bibtex         ✓ . ✓ ✓ . 
  - gomod          ✓ . . . ✓ 
  - beancount      ✓ . ✓ . . 
  - tlaplus        ✓ . ✓ . ✓ 
  - supercollider  ✓ ✓ ✓ ✓ ✓ 
  - svelte         ✓ . ✓ ✓ ✓ 
  - go             ✓ ✓ ✓ ✓ ✓ 
  - scala          ✓ . ✓ . ✓ 
  - glimmer        ✓ . . . . 
  - devicetree     ✓ ✓ ✓ ✓ ✓ 
  - godot_resource ✓ ✓ ✓ . . 
  - elixir         ✓ ✓ ✓ ✓ ✓ 
  - jsdoc          ✓ . . . . 
  - ruby           ✓ ✓ ✓ ✓ ✓ 
  - pug            ✓ . . . ✓ 
  - make           ✓ . . . ✓ 
  - toml           ✓ ✓ ✓ ✓ ✓ 
  - pascal         ✓ ✓ ✓ ✓ ✓ 
  - gowork         ✓ . . . ✓ 
  - perl           ✓ . . . . 
  - yang           ✓ . ✓ . . 
  - r              ✓ ✓ . . . 
  - dockerfile     ✓ . . . ✓ 
  - surface        ✓ . ✓ ✓ ✓ 
  - fish           ✓ ✓ ✓ ✓ ✓ 
  - lua            ✓ ✓ ✓ ✓ ✓ 
  - php            ✓ ✓ ✓ ✓ ✓ 
  - latex          ✓ . ✓ . ✓ 
  - fennel         ✓ ✓ . . ✓ 
  - ocaml          ✓ ✓ ✓ . ✓ 
  - c_sharp        ✓ ✓ ✓ . ✓ 
  - commonlisp     ✓ ✓ ✓ . . 
  - ql             ✓ ✓ . ✓ ✓ 
  - tsx            ✓ ✓ ✓ ✓ ✓ 
  - json           ✓ ✓ ✓ ✓ . 
  - query          ✓ ✓ ✓ ✓ ✓ 
  - html           ✓ ✓ ✓ ✓ ✓ 
  - ninja          ✓ . ✓ ✓ . 

  Legend: H[ighlight], L[ocals], F[olds], I[ndents], In[j]ections
         +) multiple parsers found, only one will be used
         x) errors found in the query, try to run :TSUpdate {lang}

provider: health#provider#check
========================================================================
## Clipboard (optional)
  - OK: Clipboard tool found: pbcopy

## Python 2 provider (optional)
  - INFO: Disabled (g:loaded_python_provider=0).

## Python 3 provider (optional)
  - INFO: Disabled (g:loaded_python3_provider=0).

## Python virtualenv
  - OK: no $VIRTUAL_ENV

## Ruby provider (optional)
  - INFO: Disabled (g:loaded_ruby_provider=0).

## Node.js provider (optional)
  - INFO: Disabled (g:loaded_node_provider=0).

## Perl provider (optional)
  - INFO: Disabled (g:loaded_perl_provider=0).

telescope: require("telescope.health").check()
========================================================================
## Checking for required plugins
  - OK: plenary installed.
  - OK: nvim-treesitter installed.

## Checking external dependencies
  - OK: rg: found ripgrep 13.0.0
  - OK: fd: found fd 8.3.1

## ===== Installed extensions =====

vim.lsp: require("vim.lsp.health").check()
========================================================================
  - INFO: LSP log level : WARN
  - INFO: Log path: /Users/nabezokodaikon/.cache/nvim/lsp.log
  - INFO: Log size: 1 KB

vim.treesitter: require("vim.treesitter.health").check()
========================================================================
  - INFO: Runtime ABI version : 14
  - OK: Loaded parser for bash: ABI version 13
  - OK: Loaded parser for beancount: ABI version 13
  - OK: Loaded parser for bibtex: ABI version 13
  - OK: Loaded parser for c: ABI version 13
  - OK: Loaded parser for clojure: ABI version 13
  - OK: Loaded parser for cmake: ABI version 13
  - OK: Loaded parser for comment: ABI version 13
  - OK: Loaded parser for commonlisp: ABI version 13
  - OK: Loaded parser for cpp: ABI version 13
  - OK: Loaded parser for css: ABI version 13
  - OK: Loaded parser for cuda: ABI version 13
  - OK: Loaded parser for c_sharp: ABI version 13
  - OK: Loaded parser for dart: ABI version 13
  - OK: Loaded parser for devicetree: ABI version 13
  - OK: Loaded parser for dockerfile: ABI version 13
  - OK: Loaded parser for dot: ABI version 13
  - OK: Loaded parser for elixir: ABI version 13
  - OK: Loaded parser for erlang: ABI version 13
  - OK: Loaded parser for fennel: ABI version 13
  - OK: Loaded parser for fish: ABI version 13
  - OK: Loaded parser for fusion: ABI version 13
  - OK: Loaded parser for gdscript: ABI version 13
  - OK: Loaded parser for glimmer: ABI version 13
  - OK: Loaded parser for glsl: ABI version 13
  - OK: Loaded parser for go: ABI version 13
  - OK: Loaded parser for godot_resource: ABI version 13
  - OK: Loaded parser for gomod: ABI version 13
  - OK: Loaded parser for gowork: ABI version 13
  - OK: Loaded parser for graphql: ABI version 13
  - OK: Loaded parser for hcl: ABI version 13
  - OK: Loaded parser for heex: ABI version 13
  - OK: Loaded parser for hjson: ABI version 13
  - OK: Loaded parser for hocon: ABI version 13
  - OK: Loaded parser for html: ABI version 13
  - OK: Loaded parser for http: ABI version 13
  - OK: Loaded parser for java: ABI version 13
  - OK: Loaded parser for javascript: ABI version 13
  - OK: Loaded parser for jsdoc: ABI version 13
  - OK: Loaded parser for json: ABI version 13
  - OK: Loaded parser for json5: ABI version 13
  - OK: Loaded parser for jsonc: ABI version 13
  - OK: Loaded parser for julia: ABI version 13
  - OK: Loaded parser for kotlin: ABI version 13
  - OK: Loaded parser for latex: ABI version 13
  - OK: Loaded parser for ledger: ABI version 13
  - OK: Loaded parser for llvm: ABI version 13
  - OK: Loaded parser for lua: ABI version 13
  - OK: Loaded parser for make: ABI version 13
  - OK: Loaded parser for ninja: ABI version 13
  - OK: Loaded parser for nix: ABI version 13
  - OK: Loaded parser for ocaml: ABI version 13
  - OK: Loaded parser for ocaml_interface: ABI version 13
  - OK: Loaded parser for pascal: ABI version 13
  - OK: Loaded parser for perl: ABI version 13
  - OK: Loaded parser for php: ABI version 13
  - OK: Loaded parser for pioasm: ABI version 13
  - OK: Loaded parser for prisma: ABI version 13
  - OK: Loaded parser for pug: ABI version 13
  - OK: Loaded parser for python: ABI version 13
  - OK: Loaded parser for ql: ABI version 13
  - OK: Loaded parser for query: ABI version 13
  - OK: Loaded parser for r: ABI version 13
  - OK: Loaded parser for rasi: ABI version 13
  - OK: Loaded parser for regex: ABI version 13
  - OK: Loaded parser for rst: ABI version 13
  - OK: Loaded parser for ruby: ABI version 13
  - OK: Loaded parser for rust: ABI version 13
  - OK: Loaded parser for scala: ABI version 13
  - OK: Loaded parser for scss: ABI version 13
  - OK: Loaded parser for sparql: ABI version 13
  - OK: Loaded parser for supercollider: ABI version 13
  - OK: Loaded parser for surface: ABI version 13
  - OK: Loaded parser for svelte: ABI version 13
  - OK: Loaded parser for tlaplus: ABI version 13
  - OK: Loaded parser for toml: ABI version 13
  - OK: Loaded parser for tsx: ABI version 13
  - OK: Loaded parser for turtle: ABI version 13
  - OK: Loaded parser for typescript: ABI version 13
  - OK: Loaded parser for vim: ABI version 13
  - OK: Loaded parser for vue: ABI version 13
  - OK: Loaded parser for yaml: ABI version 13
  - OK: Loaded parser for yang: ABI version 13
  - OK: Loaded parser for zig: ABI version 13

Output of nvim --version

NVIM v0.7.0-dev+914-g7717f38d3
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by nabezokodaikon@nabezokodaikonnoMacBook-Air.local

Additional context

nvim-treesitter setting.

require"nvim-treesitter.install".compilers = {"gcc"}

local treesitter = require"nvim-treesitter.configs"

treesitter.setup {
    ensure_installed = "maintained",
    highlight = {
        enable = true,
        disable = {
            "rust",
        },
    }
}
theHamsta commented 2 years ago

@clason discovered that there's a problem with the new tree-sitter-cli 0.20.3 that it doesn't generate parser.h. You will notice this when you use homebrew. You should be able to downgrade to tree-sitter-cli 0.20.2 to fix this problem.

nabezokodaikon commented 2 years ago

excuse me. How can I change the version of tree-sitter-cli?

theHamsta commented 2 years ago

I'm not on Mac but does this work. I don't know why brew install tree-sitter@0.20.2 doesn't work.

https://github.com/tree-sitter/tree-sitter/releases -> 0.20.2 and put it into your PATH before your homebrew PATH

Right now brew installs tree-sitter 0.20.3 which is the affected version. Maybe the tree-sitter team will release a hotfix

❯ brew install tree-sitter       
==> Downloading https://ghcr.io/v2/homebrew/core/tree-sitter/manifests/0.20.3
######################################################################## 100.0%
==> Downloading https://ghcr.io/v2/homebrew/core/tree-sitter/blobs/sha256:b31036d325a268ec23f76ec2740c558d1ea4f4fbcf65b6336e8c3b77c06a6af0
==> Downloading from https://pkg-containers.githubusercontent.com/ghcr1/blobs/sha256:b31036d325a268ec23f76ec2740c558d1ea4f4fbcf65b6336e8c3b77c06a6af0?se=2022-01-22T21%3A00%3A00Z&sig=G6ms2mVf4XqRGlxYtF1XDrCWwzE9hV5xnDqZY15h90I%3D&sp=r&spr=https&sr=b&sv=2019-12-12
######################################################################## 100.0%
==> Pouring tree-sitter--0.20.3.x86_64_linux.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /home/linuxbrew/.linuxbrew
Could not symlink bin/tree-sitter
Target /home/linuxbrew/.linuxbrew/bin/tree-sitter
already exists. You may want to remove it:
  rm '/home/linuxbrew/.linuxbrew/bin/tree-sitter'

To force the link and overwrite all conflicting files:
  brew link --overwrite tree-sitter

To list all files that would be deleted:
  brew link --overwrite --dry-run tree-sitter

Possible conflicting files are:
/home/linuxbrew/.linuxbrew/bin/tree-sitter -> /home/linuxbrew/.linuxbrew/lib/node_modules/tree-sitter-cli/cli.js
==> Summary
🍺  /home/linuxbrew/.linuxbrew/Cellar/tree-sitter/0.20.3: 18 files, 14.3MB
==> Running `brew cleanup tree-sitter`...
Disable this behaviour by setting HOMEBREW_NO_INSTALL_CLEANUP.
Hide these hints with HOMEBREW_NO_ENV_HINTS (see `man brew`).
Warning: Use xorgproto instead of deprecated linuxbrew/xorg/xorgproto
Warning: Use xorgproto instead of deprecated linuxbrew/xorg/xorgproto

You could also try to not install the parsers that require installation from grammar. For this you can just delete the tree-sitter binary or https://github.com/theHamsta/nvim-treesitter/blob/651d7ef33c43e13e43921f49188dcd2133c154b9/README.md#L112-L113

tree-sitter 0.20.3 will be able to generate parser that are faster to load queries for.

nabezokodaikon commented 2 years ago

thank you. I will try.

clason commented 2 years ago

@clason discovered that there's a problem with the new tree-sitter-cli 0.20.3 that it doesn't generate parser.h. You will notice this when you use homebrew. You should be able to downgrade to tree-sitter-cli 0.20.2 to fix this problem.

There is not; you just have to add the --abi flag -- that's precisely what my PR is about (which I just merged).

Max said he'll release a bugfix release next week.

(Homebrew does not allow downgrades; once a version is bumped, the old one is gone forever.)

nabezokodaikon commented 2 years ago

Where should I put the --abi option?

clason commented 2 years ago

tree-sitter generate --abi=latest

Or update nvim-treesitter, which should do this automatically now where necessary.

clason commented 2 years ago

Also, why do you override the compiler on macOS? That should not be necessary.

nabezokodaikon commented 2 years ago

I had another issue, so I just tried it.

nabezokodaikon commented 2 years ago

excuse me. Could you give us an explanation that will be possible from the beginning?

nabezokodaikon commented 2 years ago

Even if I did as I was told, it was as follows.

$ tree-sitter generate --abi=latest
No such file or directory (os error 2) 
clason commented 2 years ago

Well, yes, you actually have to tell it which grammar to generate a parser for (i.e., you have to be in a parser repo).

Really, updating nvim-treesitter should fix that issue (it did for me, unsurprisingly).

nabezokodaikon commented 2 years ago

it is complete. thank you.

jrock2004 commented 2 years ago

I am still having this issue. What was the command that people ran to fix this?

nabezokodaikon commented 2 years ago
  1. Updating nvim-treesitter
  2. Run TSUpdate