nvim-treesitter / nvim-treesitter

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

Attempt to call field `get_parser_install_dir` #3142

Closed dtomvan closed 2 years ago

dtomvan commented 2 years ago

Describe the bug

This happens for both :TSInstall c and :TSInstall markdown. I tried to install the markdown split parser, as it broke and I found out about the breaking change.

Error:

E5108: Error executing lua ...er/start/nvim-treesitter/lua/nvim-treesitter/install.lua:395: attempt to call field 'get_parser_install_dir' (a nil value)
stack traceback:
        ...er/start/nvim-treesitter/lua/nvim-treesitter/install.lua:395: in function 'run'
        [string ":lua"]:1: in main chunk

To Reproduce

  1. Install neovim nightly (version: NVIM v0.8.0-dev+504-g7e1cf6b76)
  2. Install nvim-treesitter (version: 365f0eb75f4b8)
  3. Install tree-sitter-git from the AUR (from the normal Arch Linux repo's also doesn't help)
  4. :TSInstall markdown markdown_inline (or with :TSInstallFromGrammar)

Expected behavior

nvim-treesitter should be installing the parser like normal.

Output of :checkhealth nvim-treesitter

Obviously the markdown parser isn't included, as it cannot be installed yet.

nvim-treesitter: require("nvim-treesitter.health").check()
========================================================================
## Installation
  - OK: `tree-sitter` found 0.20.6 (1f1b1eb4501ed0a2d195d37f7de15f72aa10acd0) (parser generator, only needed for :TSInstallFromGrammar)
  - OK: `node` found v14.19.3 (only needed for :TSInstallFromGrammar)
  - OK: `git` executable found.
  - OK: `cc` executable found. Selected from { vim.NIL, "cc", "gcc", "clang", "cl", "zig" }
    Version: cc (GCC) 12.1.0
  - 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
  - devicetree     ✓ ✓ ✓ ✓ ✓ 
  - latex          ✓ . ✓ . ✓ 
  - yaml           ✓ ✓ ✓ ✓ ✓ 
  - heex           ✓ ✓ ✓ ✓ ✓ 
  - tiger          ✓ ✓ ✓ ✓ ✓ 
  - help           ✓ . . . . 
  - slint          ✓ . . ✓ . 
  - proto          ✓ . ✓ . . 
  - org            . . . . . 
  - perl           ✓ . ✓ . . 
  - m68k           ✓ ✓ ✓ . ✓ 
  - wgsl           ✓ . ✓ . . 
  - prisma         ✓ . . . . 
  - c              ✓ ✓ ✓ ✓ ✓ 
  - ql             ✓ ✓ . ✓ ✓ 
  - godot_resource ✓ ✓ ✓ . . 
  - vim            ✓ ✓ ✓ . ✓ 
  - bibtex         ✓ . ✓ ✓ . 
  - rnoweb         ✓ . ✓ . ✓ 
  - gomod          ✓ . . . ✓ 
  - rst            ✓ ✓ . . ✓ 
  - json5          ✓ . . . ✓ 
  - scss           ✓ . . ✓ . 
  - hcl            ✓ . ✓ ✓ ✓ 
  - norg           ✓ . ✓ . ✓ 
  - glimmer        ✓ . . . . 
  - hack           ✓ . . . . 
  - teal           ✓ ✓ ✓ ✓ ✓ 
  - eex            ✓ . . . ✓ 
  - c_sharp        ✓ ✓ ✓ . ✓ 
  - vala           ✓ . . . . 
  - llvm           ✓ . . . . 
  - rasi           ✓ ✓ ✓ ✓ . 
  - javascript     ✓ ✓ ✓ ✓ ✓ 
  - ninja          ✓ . ✓ ✓ . 
  - css            ✓ . ✓ ✓ ✓ 
  - fortran        ✓ . ✓ ✓ . 
  - java           ✓ ✓ . ✓ ✓ 
  - hocon          ✓ . . . ✓ 
  - hjson          ✓ ✓ ✓ ✓ ✓ 
  - todotxt        ✓ . . . . 
  - scheme         ✓ . ✓ . ✓ 
  - pioasm         ✓ . . . ✓ 
  - ruby           ✓ ✓ ✓ ✓ ✓ 
  - scala          ✓ . ✓ . ✓ 
  - solidity       ✓ . . . . 
  - rego           ✓ . . . ✓ 
  - supercollider  ✓ ✓ ✓ ✓ ✓ 
  - cmake          ✓ . ✓ . . 
  - verilog        ✓ ✓ ✓ . ✓ 
  - embedded_template✓ . . . ✓ 
  - vue            ✓ . ✓ ✓ ✓ 
  - lalrpop        ✓ ✓ . . . 
  - zig            ✓ . ✓ ✓ ✓ 
  - commonlisp     ✓ ✓ ✓ . . 
  - r              ✓ ✓ . ✓ ✓ 
  - svelte         ✓ . ✓ ✓ ✓ 
  - cooklang       ✓ . . . . 
  - html           ✓ ✓ ✓ ✓ ✓ 
  - elvish         ✓ . . . ✓ 
  - sparql         ✓ ✓ ✓ ✓ ✓ 
  - tlaplus        ✓ ✓ ✓ . ✓ 
  - glsl           ✓ ✓ ✓ ✓ ✓ 
  - query          ✓ ✓ ✓ ✓ ✓ 
  - jsdoc          ✓ . . . . 
  - comment        ✓ . . . . 
  - d              ✓ . ✓ ✓ ✓ 
  - regex          ✓ . . . . 
  - fusion         ✓ ✓ ✓ ✓ . 
  - pug            ✓ . . . ✓ 
  - ocamllex       ✓ . . . ✓ 
  - ledger         ✓ . ✓ ✓ ✓ 
  - cpp            ✓ ✓ ✓ ✓ ✓ 
  - fennel         ✓ ✓ . . ✓ 
  - json           ✓ ✓ ✓ ✓ . 
  - cuda           ✓ ✓ ✓ ✓ ✓ 
  - dot            ✓ . . . ✓ 
  - pascal         ✓ ✓ ✓ ✓ ✓ 
  - yang           ✓ . ✓ ✓ . 
  - dart           ✓ ✓ . ✓ ✓ 
  - nix            ✓ ✓ ✓ . ✓ 
  - gowork         ✓ . . . ✓ 
  - make           ✓ . . . ✓ 
  - erlang         . . . . . 
  - phpdoc         ✓ . . . . 
  - surface        ✓ . ✓ ✓ ✓ 
  - foam           ✓ ✓ ✓ ✓ ✓ 
  - rust           ✓ ✓ ✓ ✓ ✓ 
  - bash           ✓ ✓ ✓ . ✓ 
  - toml           ✓ ✓ ✓ ✓ ✓ 
  - dockerfile     ✓ . . . ✓ 
  - fish           ✓ ✓ ✓ ✓ ✓ 
  - elixir         ✓ ✓ ✓ ✓ ✓ 
  - norg_meta      ✓ . . ✓ . 
  - elm            ✓ . . . ✓ 
  - norg_table     ✓ . . . ✓ 
  - clojure        ✓ ✓ ✓ . ✓ 
  - lua            ✓ ✓ ✓ ✓ ✓ 
  - haskell        ✓ . . . ✓ 
  - gdscript       ✓ ✓ . ✓ ✓ 
  - php            ✓ ✓ ✓ ✓ ✓ 
  - kotlin         ✓ ✓ ✓ . ✓ 
  - go             ✓ ✓ ✓ ✓ ✓ 
  - jsonc          ✓ ✓ ✓ ✓ ✓ 
  - gleam          ✓ ✓ ✓ ✓ ✓ 
  - julia          ✓ ✓ ✓ ✓ ✓ 
  - python         ✓ ✓ ✓ ✓ ✓ 
  - graphql        ✓ . . ✓ ✓ 
  - turtle         ✓ ✓ ✓ ✓ ✓ 

  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}

Output of nvim --version

NVIM v0.8.0-dev+504-g7e1cf6b76
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by tomvd

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/local/share/nvim"

Run :checkhealth for more info

Additional context

Issue before uninstalling the markdown parser: #3092 I followed the guide in that issue, which told me to do:

:echo nvim_get_runtime_file('*/markdown.so', v:true)
['/home/tomvd/.local/share/nvim/site/parser/markdown.so']

:echo nvim_get_runtime_file('queries/<lang>/*.scm', v:true)
['/home/tomvd/.local/share/nvim/site/pack/packer/start/nvim-treesitter/queries/markdown/folds.scm', '/home/tomvd/.local/share/nvim/site/pack/packer/start/nvim-treesitter/queries/markdown/highlights.scm', '/home
/tomvd/.local/share/nvim/site/pack/packer/start/nvim-treesitter/queries/markdown/injections.scm']

Note the first output. It had put the parser in ~/.local/share/nvim/site/pack/parser, not in nvim-treesitter/parser. Following the guide, I removed the file and reinstalled using :TSInstall, which caused this issue.

Edit: removed the double code block added by the issue form

theHamsta commented 2 years ago

Have you checked whether the reported method is actually present in your local copy of plugins? Is it possible that you have an additional copy of nvim-treesitter in some place or another plugin with conflicting require path?

dtomvan commented 2 years ago

In ~/.local/share/nvim/site/pack/packer the method is defined. I do use Nix for managing a small portion of my neovim config, but I don't have the plugin included in my home.nix and I have done a home-manager switch to confirm the plugin is not there. If I remember correctly, I have to search my 'packpath' to find any other directory it may be installed in, right?

dtomvan commented 2 years ago

Also, I will try to make a minimum setup, to figure out if the problem lies with me or if it is an actual issue with the plugin. With your comment, I am starting to believe it's my problem though.

dtomvan commented 2 years ago

Searching the runtime path:

:lua=vim.api.nvim_get_runtime_file('lua/nvim-treesitter/', true)
{ "/home/tomvd/.local/share/nvim/site/pack/packer/start/nvim-treesitter/lua/nvim-treesitter/" }
dtomvan commented 2 years ago

Minimal setup:

rm -rf ~/.config/nvim/{plugin,autoload,ftplugin}/*
nvim -u NONE
:packadd nvim-treesitter " Works as it is already installed on the latest version by packer, as confirmed in previous comments
:checkhealth nvim-treesitter " Works, prints the exact same output as in the first comment in this issue
:TSInstall c markdown markdown_inline " Works as well

I am sorry for bothering you, this is probably a problem with how I set up my nvim-treesitter somewhere in my lua config. I should have done further investigation first.

dtomvan commented 2 years ago

Closing. Fixed by recompiling my packer_compiled.lua.