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

bug: Encountered Error detected while processing BufReadPost Autocommands for "*": while loading a Lua file failing in Neovim nightly #1343

Closed
3 tasks done
ColinKennedy opened this issue Feb 28, 2024 · 10 comments · Fixed by #1643
Labels
bug Something isn't working

Comments

@ColinKennedy
Copy link

ColinKennedy commented Feb 28, 2024

Did you check docs and existing issues?

  • I have read all the lazy.nvim docs
  • I have searched the existing issues of lazy.nvim
  • I have searched the existing issues of plugins related to this issue

Neovim version (nvim -v)

NVIM v0.10.0-dev-2465+ga7788c2e2

Operating system/version

CentOS Linux 7 (Core)

Describe the bug

Error when loading any .lua file on-start-up.

Error detected while processing BufReadPost Autocommands for "*":                                                             
Error executing lua callback: /usr/local/share/nvim/runtime/filetype.lua:30: Error executing lua: /usr/local/share/nvim/runtim
e/filetype.lua:31: BufReadPost Autocommands for "*"..FileType Autocommands for "*"..function <SNR>1_LoadFTPlugin[20]..script /
usr/local/share/nvim/runtime/ftplugin/lua.lua: Vim(runtime):E5113: Error while calling lua chunk: ...local/share/nvim/runtime/
lua/vim/treesitter/language.lua:102: no parser for 'lua' language, see :help treesitter-parsers                               
stack traceback:                                                                                                              
        [C]: in function 'error'                                                                                              
        ...local/share/nvim/runtime/lua/vim/treesitter/language.lua:102: in function 'add'                                    
        ...l/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:111: in function 'new'                                    
        /usr/local/share/nvim/runtime/lua/vim/treesitter.lua:41: in function '_create_parser'                                 
        /usr/local/share/nvim/runtime/lua/vim/treesitter.lua:108: in function 'get_parser'                                    
        /usr/local/share/nvim/runtime/lua/vim/treesitter.lua:452: in function 'start'                                         
        /usr/local/share/nvim/runtime/ftplugin/lua.lua:2: in main chunk                                                       
        [C]: in function 'nvim_cmd'                                                                                           
        /usr/local/share/nvim/runtime/filetype.lua:31: in function </usr/local/share/nvim/runtime/filetype.lua:30>            
        [C]: in function 'nvim_buf_call'                                                                                      
        /usr/local/share/nvim/runtime/filetype.lua:30: in function </usr/local/share/nvim/runtime/filetype.lua:10>            
stack traceback:                                                                                                              
        [C]: in function 'nvim_cmd'                                                                                           
        /usr/local/share/nvim/runtime/filetype.lua:31: in function </usr/local/share/nvim/runtime/filetype.lua:30>            
        [C]: in function 'nvim_buf_call'                                                                                      
        /usr/local/share/nvim/runtime/filetype.lua:30: in function </usr/local/share/nvim/runtime/filetype.lua:10>            
stack traceback:                                                                                                              
        [C]: in function 'nvim_buf_call'                                                                                      
        /usr/local/share/nvim/runtime/filetype.lua:30: in function </usr/local/share/nvim/runtime/filetype.lua:10>            
Press ENTER or type command to continue                                                                                       

And just in case, here's my :checkhealth

:checkhealth output

==============================================================================
lazy: require("lazy.health").check()

lazy.nvim ~
- OK Git installed
- OK no existing packages found by other package managers
- OK packer_compiled.lua not found

==============================================================================
nvim: require("nvim.health").check()

Configuration ~
- WARNING Missing user config file: /home/selecaoone/personal/.config/nvim/.repro//config/nvim/init.lua
  - ADVICE:
    - :help |config|

Runtime ~
- OK $VIMRUNTIME: /usr/local/share/nvim/runtime

Performance ~
- OK Build type: RelWithDebInfo

Remote Plugins ~
- OK Up to date

terminal ~
- key_backspace (kbs) terminfo entry: `key_backspace=\177`
- key_dc (kdch1) terminfo entry: `key_dc=\E[3~`
- $VTE_VERSION="5204"
- $TERM_PROGRAM="tmux"
- $COLORTERM="truecolor"

tmux ~
- OK escape-time: 10
- OK focus-events: on
- $TERM: screen-256color

==============================================================================
provider.clipboard: require("provider.clipboard.health").check()

Clipboard (optional) ~
- OK Clipboard tool found: xsel

==============================================================================
provider.node: require("provider.node.health").check()

Node.js provider (optional) ~
- Node.js: v14.21.3
  
- WARNING Missing "neovim" npm (or yarn, pnpm) package.
  - ADVICE:
    - Run in shell: npm install -g neovim
    - Run in shell (if you use yarn): yarn global add neovim
    - Run in shell (if you use pnpm): pnpm install -g neovim
    - You may disable this provider (and warning) by adding `let g:loaded_node_provider = 0` to your init.vim

==============================================================================
provider.perl: require("provider.perl.health").check()

Perl provider (optional) ~
- WARNING Perl version is too old, 5.22+ required
  - ADVICE:
    - See :help |provider-perl| for more information.
    - You may disable this provider (and warning) by adding `let g:loaded_perl_provider = 0` to your init.vim
- WARNING No usable perl executable found

==============================================================================
provider.python: require("provider.python.health").check()

Python 3 provider (optional) ~
- `g:python3_host_prog` is not set. Searching for python3.9 in the environment.
- Executable: /usr/local/bin/python3.9
- Python version: 3.9.18
- pynvim version: 0.5.0
- OK Latest pynvim is installed.

Python virtualenv ~
- OK no $VIRTUAL_ENV

==============================================================================
provider.ruby: require("provider.ruby.health").check()

Ruby provider (optional) ~
- Ruby: ruby 2.0.0p648 (2015-12-16) [x86_64-linux]
- WARNING `neovim-ruby-host` not found.
  - ADVICE:
    - Run `gem install neovim` to ensure the neovim RubyGem is installed.
    - Run `gem environment` to ensure the gem bin directory is in $PATH.
    - If you are using rvm/rbenv/chruby, try "rehashing".
    - See :help |g:ruby_host_prog| for non-standard gem installations.
    - You may disable this provider (and warning) by adding `let g:loaded_ruby_provider = 0` to your init.vim

==============================================================================
vim.lsp: require("vim.lsp.health").check()

- LSP log level : WARN
- Log path: /home/selecaoone/personal/.config/nvim/.repro/state/nvim/lsp.log
- Log size: 0 KB

vim.lsp: Active Clients ~
- No active clients

==============================================================================
vim.treesitter: require("vim.treesitter.health").check()

- Nvim runtime ABI version: 14

This error does not occur on NVIM v0.9.4. Neovim nightly recently started shipping a tree-sitter parser for Lua which may be the cause of this error. By the way, the recommended, base reproduction file in this GitHub template reproduces the issue.

Steps To Reproduce

  1. echo "print('hello')" > file.lua
  2. nvim -u reproduction.lua file.lua

Expected Behavior

Normal startup and loading the file.lua file.

Repro

-- DO NOT change the paths and don't remove the colorscheme
local root = vim.fn.fnamemodify("./.repro", ":p")

-- set stdpaths to use .repro
for _, name in ipairs({ "config", "data", "state", "cache" }) do
  vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name
end

-- bootstrap lazy
local lazypath = root .. "/plugins/lazy.nvim"
if not vim.loop.fs_stat(lazypath) then
  vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, })
end
vim.opt.runtimepath:prepend(lazypath)

-- install plugins
local plugins = {
  "folke/tokyonight.nvim",
  -- add any other plugins here
}
require("lazy").setup(plugins, {
  root = root .. "/plugins",
})

vim.cmd.colorscheme("tokyonight")
-- add anything else here
@ColinKennedy ColinKennedy added the bug Something isn't working label Feb 28, 2024
@barrett-ruth
Copy link

Also finding this. Attaching event = BufReadPre fixed it for me as a temporary solution.

@Abastro
Copy link

Abastro commented Mar 8, 2024

Just encountered this as well, does lazy.nvim cause issues in treesitter?

@ColinKennedy
Copy link
Author

Also finding this. Attaching event = BufReadPre fixed it for me as a temporary solution.

@barrett-ruth sorry do you mean you added this to lazy.nvim somehow or to a specific plugin?

@folke
Copy link
Owner

folke commented Mar 8, 2024

Just tested this and the repro works fine for me.

The lua treesitter parser is included in Neovim, so I suspect your Neovim binary and its RUNTIME are not in sync.

Try re-installing Neovim.

Either way, this is not a lazy issue. Closing...

@folke folke closed this as not planned Won't fix, can't repro, duplicate, stale Mar 8, 2024
@ColinKennedy
Copy link
Author

I removed all Neovim files and make distclean + installed Neovim from scratch. Still the same error

`:scriptnames` output
:scriptnames                                                                                                                  
  1: /usr/local/share/nvim/runtime/ftplugin.vim                                                                               
  2: /usr/local/share/nvim/runtime/indent.vim                                                                                 
  3: /tmp/repro.lua                                                                                                           
  4: /usr/local/share/nvim/runtime/filetype.lua                                                                               
  5: /usr/local/share/nvim/runtime/plugin/editorconfig.lua                                                                    
  6: /usr/local/share/nvim/runtime/plugin/gzip.vim                                                                            
  7: /usr/local/share/nvim/runtime/plugin/man.lua                                                                             
  8: /usr/local/share/nvim/runtime/plugin/matchit.vim                                                                         
  9: /usr/local/share/nvim/runtime/pack/dist/opt/matchit/plugin/matchit.vim                                                   
 10: /usr/local/share/nvim/runtime/plugin/matchparen.vim                                                                      
 11: /usr/local/share/nvim/runtime/plugin/netrwPlugin.vim                                                                     
 12: /usr/local/share/nvim/runtime/plugin/nvim.lua                                                                            
 13: /usr/local/share/nvim/runtime/plugin/osc52.lua                                                                           
 14: /usr/local/share/nvim/runtime/plugin/rplugin.vim                                                                         
 15: /usr/local/share/nvim/runtime/plugin/shada.vim                                                                           
 16: /usr/local/share/nvim/runtime/plugin/spellfile.vim                                                                       
 17: /usr/local/share/nvim/runtime/plugin/tarPlugin.vim                                                                       
 18: /usr/local/share/nvim/runtime/plugin/tohtml.lua                                                                          
 19: /usr/local/share/nvim/runtime/plugin/tutor.vim                                                                           
 20: /usr/local/share/nvim/runtime/plugin/zipPlugin.vim                                                                       
 21: /tmp/.repro/plugins/tokyonight.nvim/colors/tokyonight.lua                                                                
 22: /usr/local/share/nvim/runtime/syntax/syntax.vim                                                                          
 23: /usr/local/share/nvim/runtime/syntax/synload.vim                                                                         
 24: /usr/local/share/nvim/runtime/ftplugin/lua.vim                                                                           
 25: /usr/local/share/nvim/runtime/ftplugin/lua.lua                                                                           
 26: /usr/local/share/nvim/runtime/ftplugin/vim.vim                                                                           
 27: /usr/local/share/nvim/runtime/indent/vim.vim                                                                             
 28: /usr/local/share/nvim/runtime/syntax/vim.vim                                                                             
 29: /usr/local/share/nvim/runtime/syntax/lua.vim                                                                             
 30: /usr/local/share/nvim/runtime/syntax/vim/generated.vim                         

The /usr/local/share/nvim folder was removed and recreated. The missing parser that Neovim complains about is lua, which is located in /usr/local/lib64/nvim/parser/lua.so. /usr/local/lib64/nvim was also freshly deleted and recreated on-compile.

I tried adding vim.opt.runtimepath:append("/usr/local/lib64/nvim/parser") to init.lua before lazy.nvim loads to encourage it to see the parsers. No luck. I'm stumped. If anyone had this error and got it working, what did you do? I'm still curious about @barrett-ruth 's solution

@willeccles
Copy link

willeccles commented Jul 12, 2024

This issue should be reopened, as Lazy is making the invalid assumption that /usr/local/lib/nvim is the correct location. When resetting rtp, Lazy explicitly only adds lib instead of lib64. Setting performance.rtp.reset = false in Lazy's config fixes this issue. See neovim/neovim#29680.

The ideal fix for this would be to check vim.o.rtp first, find the correct library directory, and reuse it when resetting.

@yorickpeterse
Copy link

yorickpeterse commented Jul 13, 2024

This bug also manifests itself on Fedora, as it ships Neovim's built-in parsers in /usr/lib64/nvim which is removed from runtimepath by Lazy (see this comment for more details).

@folke folke reopened this Jul 13, 2024
@folke folke closed this as completed in 93499c5 Jul 13, 2024
@folke
Copy link
Owner

folke commented Jul 13, 2024

I think I just fixed that.

would be great if anyone can verify, since I use bob and that's not an issue there

@Silejonu
Copy link

I think I just fixed that.

would be great if anyone can verify, since I use bob and that's not an issue there

It's fixed indeed, thanks for the quick update!

folke pushed a commit that referenced this issue Jul 13, 2024
🤖 I have created a release *beep* *boop*
---


##
[11.11.1](v11.11.0...v11.11.1)
(2024-07-13)


### Bug Fixes

* **config:** check for lib64. Fixes
[#1343](#1343)
([93499c5](93499c5))
* **lockfile:** ensure newline at EOF for lockfile
([#1639](#1639))
([7ed9f71](7ed9f71))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@savchenko
Copy link

@folke, The issue persists if nvim-treesitter config contains lazy = false.

New installation of nVim 0.10.1 and latest stable lazy.nvim causes Treesitter to stop working for all Lua files. Error output:

Diagnostic in code turned OFF
Error detected while processing BufReadPost Autocommands for "*":
Error executing lua callback: /usr/share/nvim/runtime/filetype.lua:35: Error executing lua: /usr/share/nvim/runtime/filetype.lua:36: BufReadPost Autocommands for "*"..FileType Autoc
ommands for "*"..function <SNR>1_LoadFTPlugin[20]..script /usr/share/nvim/runtime/ftplugin/lua.lua: Vim(runtime):E5113: Error while calling lua chunk: /usr/share/nvim/runtime/lua/vi
m/treesitter/language.lua:107: no parser for 'lua' language, see :help treesitter-parsers
stack traceback:
        [C]: in function 'error'
        /usr/share/nvim/runtime/lua/vim/treesitter/language.lua:107: in function 'add'
        /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:111: in function 'new'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:41: in function '_create_parser'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:108: in function 'get_parser'
        /usr/share/nvim/runtime/lua/vim/treesitter.lua:416: in function 'start'
        /usr/share/nvim/runtime/ftplugin/lua.lua:2: in main chunk
        [C]: in function 'nvim_cmd'
        /usr/share/nvim/runtime/filetype.lua:36: in function </usr/share/nvim/runtime/filetype.lua:35>
        [C]: in function 'nvim_buf_call'
        /usr/share/nvim/runtime/filetype.lua:35: in function </usr/share/nvim/runtime/filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_cmd'
        /usr/share/nvim/runtime/filetype.lua:36: in function </usr/share/nvim/runtime/filetype.lua:35>
        [C]: in function 'nvim_buf_call'
        /usr/share/nvim/runtime/filetype.lua:35: in function </usr/share/nvim/runtime/filetype.lua:10>
stack traceback:
        [C]: in function 'nvim_buf_call'
        /usr/share/nvim/runtime/filetype.lua:35: in function </usr/share/nvim/runtime/filetype.lua:10>

After installing Lazy with the default settings, TS lua parser obtained with :TSInstall is at ~/.local/share/nvim/lazy/nvim-treesitter/parser/lua.so while default parser is at /usr/lib/nvim/parser/lua.so.

There are no issues with Lua files if nvim is started with --clean.

Lastly, this was discussed at Fedora Bugtracker.

Changing to lazy = false makes nVim able to load Lua files without TS failure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants