L3MON4D3 / LuaSnip

Snippet Engine for Neovim written in Lua.
Apache License 2.0
3.2k stars 232 forks source link

Luasnip autocommand error when opening Telescope #1075

Closed prdanelli closed 7 months ago

prdanelli commented 7 months ago

Following error when opening Telescope with auto insert mode active.

vim/_editor.lua:0: InsertEnter Autocommands for "*"..script nvim_exec2() called at InsertEnter Autocommands for "*":0../Users/pa
ul/.local/share/nvim/lazy/LuaSnip/plugin/luasnip.lua: Vim(source):E5113: Error while calling lua chunk: ...cal/share/nvim/lazy/L
uaSnip/lua/luasnip/loaders/init.lua:1: module 'luasnip.loaders._caches' not found:
        no field package.preload['luasnip.loaders._caches']
cache_loader: module luasnip.loaders._caches not found
cache_loader_lib: module luasnip.loaders._caches not found
        no file './luasnip/loaders/_caches.lua'
        no file '/opt/homebrew/share/luajit-2.1/luasnip/loaders/_caches.lua'
        no file '/usr/local/share/lua/5.1/luasnip/loaders/_caches.lua'
        no file '/usr/local/share/lua/5.1/luasnip/loaders/_caches/init.lua'
        no file '/opt/homebrew/share/lua/5.1/luasnip/loaders/_caches.lua'
        no file '/opt/homebrew/share/lua/5.1/luasnip/loaders/_caches/init.lua'
        no file './luasnip/loaders/_caches.so'
        no file '/usr/local/lib/lua/5.1/luasnip/loaders/_caches.so'
        no file '/opt/homebrew/lib/lua/5.1/luasnip/loaders/_caches.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file './luasnip.so'
        no file '/usr/local/lib/lua/5.1/luasnip.so'
        no file '/opt/homebrew/lib/lua/5.1/luasnip.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
stack traceback:
        [C]: in function 'require'
        ...cal/share/nvim/lazy/LuaSnip/lua/luasnip/loaders/init.lua:1: in main chunk
        [C]: in function 'require'
        ...paul/.local/share/nvim/lazy/LuaSnip/lua/luasnip/init.lua:10: in main chunk
        [C]: in function 'require'
        ...ul/.local/share/nvim/lazy/LuaSnip/lua/luasnip/config.lua:257: in function '_setup'
        ...s/paul/.local/share/nvim/lazy/LuaSnip/plugin/luasnip.lua:79: in main chunk
        [C]: in function 'nvim_exec2'
        vim/_editor.lua: in function 'cmd'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:481: in function <...local/share/nvim/lazy/lazy.nvim/lua/laz
y/core/loader.lua:480>
        [C]: in function 'xpcall'
        ...
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:439: in function 'source_runtime'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:407: in function 'packadd'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:342: in function '_load'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:187: in function 'load'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:338: in function <...local/share/nvim/lazy/lazy.nvim/lua/laz
y/core/loader.lua:337>
        [C]: in function 'xpcall'
        .../.local/share/nvim/lazy/lazy.nvim/lua/lazy/core/util.lua:113: in function 'try'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:337: in function '_load'
        ...local/share/nvim/lazy/lazy.nvim/lua/lazy/core/loader.lua:187: in function 'load'
        ...hare/nvim/lazy/lazy.nvim/lua/lazy/core/handler/event.lua:83: in function <...hare/nvim/lazy/lazy.nvim/lua/lazy/core/h
andler/event.lua:72>

# stacktrace:
  - vim/_editor.lua:0 _in_ **cmd**
❯ nvim -v
NVIM v0.9.4
Build type: Release
LuaJIT 2.1.1700008891

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/opt/homebrew/Cellar/neovim/0.9.4/share/nvim"
semanticart commented 7 months ago

I'm getting a similar error after updating luasnip.

L3MON4D3 commented 7 months ago

I'm fairly certain this issue occurs because of an unclean update (there may be another luasnip-installation in your runtimepath), or somehow originates from outside luasnip (doubt this honestly, but that error-message is not complete, so don't want to rule that out just yet) since luasnip itself does not contain any reference to the deleted module _caches. The former issue often happens due to an unclean transition from packer to lazy.nvim, maybe thats the case here?

semanticart commented 7 months ago

The former issue often happens due to an unclean transition from packer to lazy.nvim, maybe thats the case here?

Might be! What's the best way to clear out any old data and start fresh? Should I nuke all the luasnip directories that show up in the stacktrace?

JamyGolden commented 7 months ago

@semanticart I have just had the same problem. I have my nvim config under ~/.config/nvim so running rm -r ~/.config/nvim/lua/snippets solved it for me.

L3MON4D3 commented 7 months ago

You could take a look at your runtimepath (or even use an API like get_runtime_file (think that's it) to find directories that have a lua/luasnip/init.lua), if there is more than one entry for luasnip, one of them is certainly at fault :)

semanticart commented 7 months ago

Thank you. I'm back to good again with a fresh install 😄

prdanelli commented 7 months ago

Seems like removing the Lazy entries, cleaning and reinstalling fixe the issue. 👍🏻