p00f/nvim-ts-rainbow

E5108: Error executing lua vim.lua:372: attempt to call method 'byte' (a nil value)

hrqmonteiro opened this issue · 20 comments

Describe the bug

E5108: Error executing lua vim.lua:372: attempt to call method 'byte' (a nil value)                                                                                                     
stack traceback:                                                                                                                                                                        
        vim.lua:372: in function 'region'                                                                                                                                               
        /usr/local/share/nvim/runtime/lua/vim/highlight.lua:35: in function 'range'                                                                                                     
        ...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:63: in function 'update_range'                                                                                      
        ...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:98: in function 'fn'                                                                                                
        ...l/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:194: in function 'for_each_tree'                                                                                    
        ...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:97: in function 'full_update'                                                                                       
        ...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:160: in function 'attach'                                                                                           
        ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:459: in function 'attach_module'                                                                                    
        ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:482: in function 'reattach_module'                                                                                  
        [string ":lua"]:1: in main chunk                

Steps to reproduce
Just try to open any file and it shows up if i have the rainbow enabled.

Expected behavior
Not to have this error?

Screenshots
Screenshot from 2022-03-01 13-00-11
Screenshot from 2022-03-01 13-03-51

p00f commented

nvim -v should be pasted instead of being a screenshot. Also I can't find that commit anywhere in neovim's git log

i have same error:

Error detected while processing FileType Autocommands for "*":
E5108: Error executing lua vim.lua:372: attempt to call method 'byte' (a nil value)
stack traceback:
vim.lua:372: in function 'region'
/usr/share/nvim/runtime/lua/vim/highlight.lua:35: in function 'range'
...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:63: in function 'update_range'
...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:98: in function 'fn'
/usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:194: in function 'for_each_tree'
...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:97: in function 'full_update'
...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:160: in function 'attach'
...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:459: in function 'attach_module'
...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:482: in function 'reattach_module'
[string ":lua"]:1: in main chunk
<
my nvim -v:

NVIM v0.7.0-dev+672-g1e6eeca9d
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az65-553

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

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

Run :checkhealth for more info
<

i have same error:

Error detected while processing FileType Autocommands for "*": E5108: Error executing lua vim.lua:372: attempt to call method 'byte' (a nil value) stack traceback: vim.lua:372: in function 'region' /usr/share/nvim/runtime/lua/vim/highlight.lua:35: in function 'range' ...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:63: in function 'update_range' ...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:98: in function 'fn' /usr/share/nvim/runtime/lua/vim/treesitter/languagetree.lua:194: in function 'for_each_tree' ...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:97: in function 'full_update' ...ck/packer/start/nvim-ts-rainbow/lua/rainbow/internal.lua:160: in function 'attach' ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:459: in function 'attach_module' ...er/start/nvim-treesitter/lua/nvim-treesitter/configs.lua:482: in function 'reattach_module' [string ":lua"]:1: in main chunk < my nvim -v:

NVIM v0.7.0-dev+672-g1e6eeca9d Build type: RelWithDebInfo LuaJIT 2.1.0-beta3 Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include Compiled by runner@fv-az65-553

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

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

Run :checkhealth for more info <

I think everyone is having this error.

nvim -v should be pasted instead of being a screenshot. Also I can't find that commit anywhere in neovim's git log

I literally cloned again the neovim/neovim repo and make && make install neovim two hours ago, my version it's the literal last commit.

Edit, forgot to add:

NVIM v0.7.0-dev+1165-ged1a9c310
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/minutrade/neovim/build/config -I/home/minutrade/neovim/src -I/home/minutrade/neovim/.deps/usr/include -I/usr/include -I/home/minutrade/neovim/build/src/nvim/auto -I/home/minutrade/neovim/build/include
Compiled by minutrade@MT2026-UBUNTU

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
p00f commented

@PablloSC your neovim is from 4 December, you need to update

p00f commented

@hrqmonteiro I can't reproduce this with any file, can you send one?

@p00f for me, this happens when I open ~/.config/nvim/init.lua.

`nvim -v`
NVIM v0.7.0-dev+711-g3f8703093
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az139-104

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

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"
p00f commented

@tversteeg your neovim is from 10 December

I've downgraded to the latest Debian repository version and now everything works again.

p00f commented

Yes - either use a stable release or the latest version of nightly (not 3 months old)

@p00f for me, this happens when I open ~/.config/nvim/init.lua.
nvim -v

NVIM v0.7.0-dev+711-g3f8703093
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /usr/bin/gcc-11 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -O2 -g -Og -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -D_GNU_SOURCE -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/home/runner/work/neovim/neovim/build/config -I/home/runner/work/neovim/neovim/src -I/home/runner/work/neovim/neovim/.deps/usr/include -I/usr/include -I/home/runner/work/neovim/neovim/build/src/nvim/auto -I/home/runner/work/neovim/neovim/build/include
Compiled by runner@fv-az139-104

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

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "
/home/runner/work/neovim/neovim/build/nvim.AppDir/usr/share/nvim"

Same thing here, but also happens on my TypeScript/JavaScript files, so that's what's a bummer for me right now.

p00f commented

Same thing here

I can't reproduce with that file either

i back to version v0.6.1 and works, thanks

Same thing here

I can't reproduce with that file either

Do you realize that, even though YOU can't reproduce, this is happening with more than one person? So saying that you can't reproduce doesn't help, right?

p00f commented

No, this is only happening with you. Everyone else used wrong versions of neovim. Me saying that I can't reproduce means that you are on your own, good luck.

I can confirm that bumping neovim helped. I though I had it updated but it turned out brew bundle was swallowing rebase error in git repo. After cleaning it up and executing brew upgrade ... I no longer see this error na it was relevant for me in lua, python, json and yml sources.

NVIM v0.7.0-dev+1182-ge23af71d3
Build type: Release
LuaJIT 2.1.0-beta3

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

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

Run :checkhealth for more info

hey i had the same problem there is some problem with nvim nightly because i downgraded from nvim-nightly to nvim and its now working

Yes chiming in to say nightly caused issue for me too. Not sure if breaking change or not but FYI.

NOTE: My Version for reference

NVIM v0.7.0-dev+1269-g746a29c58
Build type: RelWithDebInfo
LuaJIT 2.1.0-beta3
Compilation: /Applications/Xcode_12.4.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 -DNVIM_TS_HAS_SET_MATCH_LIMIT -DNVIM_TS_HAS_SET_ALLOCATOR -O2 -g -Wall -Wextra -pedantic -Wno-unused-parameter -Wstrict-prototypes -std=gnu99 -Wshadow -Wconversion -Wmissing-prototypes -Wimplicit-fallthrough -Wvla -fstack-protector-strong -fno-common -fdiagnostics-color=always -DINCLUDE_GENERATED_DECLARATIONS -DNVIM_MSGPACK_HAS_FLOAT32 -DNVIM_UNIBI_HAS_VAR_FROM -DMIN_LOG_LEVEL=3 -I/Users/runner/work/neovim/neovim/build/config -I/Users/runner/work/neovim/neovim/src -I/Users/runner/work/neovim/neovim/.deps/usr/include -I/Applications/Xcode_12.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.1.sdk/usr/include -I/Library/Frameworks/Mono.framework/Headers -I/Users/runner/work/neovim/neovim/build/src/nvim/auto -I/Users/runner/work/neovim/neovim/build/include
Compiled by runner@Mac-1647490340375.local

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

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

Run :checkhealth for more info

Same issue on v0.7.0 stable from homebrew.

I have exactly same problem, after some study of traceback, it looks like related to wrong version of runtime:
There were some changes on range function's argument in runtime/lua/vim/highlight.lua.
After updating to latest runtime, problem resolved.

runtime/lua/vim/highlight.lua (argument changes)
image

nvim-ts-rainbow/lua/rainbow/internal.lua (calling range function above)
image