Shougo/dein.vim

Race of nvim-treesitter automatic installation

e-kwsm opened this issue · 3 comments

Warning: I will close the issue without the minimal init.vim and the
reproduction instructions.

Problems summary

Race occurs if nvim-treesitter is managed by dein and automatic installation is enabled.
An error message would look like:

[nvim-treesitter] [0/2] Downloading tree-sitter-python...
[nvim-treesitter] [0/2] Downloading tree-sitter-python...
[nvim-treesitter] [0/2] Creating temporary directory
[nvim-treesitter] [0/2] Extracting tree-sitter-python...
[nvim-treesitter] [0/2] Creating temporary directory
Error detected while processing command line:
nvim-treesitter[python]: Could not create tree-sitter-python-tmp
mkdir: cannot create directory 'tree-sitter-python-tmp': File exists
[nvim-treesitter] [1/2, failed: 1] Compiling...
[nvim-treesitter] [2/2, failed: 1] Treesitter parser for python has been installed
[nvim-treesitter] [0/2] Downloading tree-sitter-python...
[nvim-treesitter] [0/2] Downloading tree-sitter-python...
[nvim-treesitter] [0/2] Creating temporary directory
[nvim-treesitter] [0/2] Extracting tree-sitter-python...
[nvim-treesitter] [0/2] Compiling...
[nvim-treesitter] [0/2] Creating temporary directory
[nvim-treesitter] [0/2] Extracting tree-sitter-python...
Error detected while processing command line:
nvim-treesitter[python]: Error during tarball extraction.
tar (child): tree-sitter-python.tar.gz: Cannot open: No such file or directory
tar (child): Error is not recoverable: exiting now
tar: Child returned status 2
tar: Error is not recoverable: exiting now
[nvim-treesitter] [2/2, failed: 1] Treesitter parser for python has been installed
[nvim-treesitter] [0/2] Downloading tree-sitter-python...
[nvim-treesitter] [0/2] Downloading tree-sitter-python...
[nvim-treesitter] [0/2] Creating temporary directory
[nvim-treesitter] [0/2] Extracting tree-sitter-python...
[nvim-treesitter] [0/2] Compiling...
[nvim-treesitter] [0/2] Creating temporary directory
[nvim-treesitter] [0/2] Extracting tree-sitter-python...
[nvim-treesitter] [0/2] Compiling...
[nvim-treesitter] [1/2] Treesitter parser for python has been installed
Error detected while processing command line:
nvim-treesitter[python]: Error during compilation
cc1plus: fatal error: src/scanner.cc: No such file or directory
compilation terminated.

Expected

No race occurs.

Environment Information (Required!)

  • dein.vim version(SHA1): 5c9db5d
  • OS: EndeavourOS
  • neovim/Vim :version output: NVIM v0.9.0-dev-439+gb866d8d2e

Provide a minimal init.vim/vimrc without plugin managers (Required!)

let s:dein_base = '/tmp/dein'

set runtimepath+=/path/to/dein.vim

if exists('g:without_dein') && g:without_dein
  " no race
  let &runtimepath .= ',' . s:dein_base . '/repos/github.com/nvim-treesitter/nvim-treesitter'
else
  " race
  call dein#begin(s:dein_base)
  call dein#add('nvim-treesitter/nvim-treesitter')
  call dein#end()
  if dein#check_install()
    call dein#install()
  endif
endif

lua << EOF
require'nvim-treesitter.configs'.setup {
  auto_install = true,
}
EOF

How to reproduce the problem from neovim/Vim startup (Required!)

Here python parser is chosen as example:

  1. Make sure the parser is not installed: nvim --headless -u vimrc -c 'TSUninstall python' -c q
  2. Open a Python file: nvim --headless -u vimrc -c 'sleep 4' -c q a.py

Race does not occur for the followings:

  • nvim --headless -u vimrc -c 'TSInstall python' -c 'sleep 4' -c q
  • nvim --headless -u vimrc -c 'setf python' -c 'sleep 4' -c q

Screen shot (if possible)

Upload the log messages by :redir and :message (if errored)

Sorry. It is not dein.vim's problem.
In the example, dein.vim just add nvim-treesitter to runtimepath.

If it has the race condition, it is in nvim-treesitter upgrade process.

If you think it is the problem in dein.vim, please provide what the code is wrong. I will check it later.

I get the reason.

nvim-treesitter must be filetype plugin indent on.
But dein.vim disables it because performance reason. So you need to enable it manually.

filetype plugin indent on

is needed in your init.vim. It is not bug.

I see, thank you.