nvim-neorocks / rocks.nvim

Neovim plugin management inspired by Cargo, powered by luarocks
GNU General Public License v3.0
379 stars 6 forks source link

`luarocks.core.path` not found #261

Closed tarcisioe closed 1 month ago

tarcisioe commented 1 month ago

After upgrading rocks.nvim I have been getting this error when neovim opens:

Failed to initialize luarocks loader: /usr/share/lua/5.4/luarocks/loader.lua:26: module 'luarocks.core.path' not found:
        no field package.preload['luarocks.core.path']
        no file './luarocks/core/path.lua'
        no file '/usr/share/luajit-2.1/luarocks/core/path.lua'
        no file '/usr/local/share/lua/5.1/luarocks/core/path.lua'
        no file '/usr/local/share/lua/5.1/luarocks/core/path/init.lua'
        no file '/usr/share/lua/5.1/luarocks/core/path.lua'
        no file '/usr/share/lua/5.1/luarocks/core/path/init.lua'
        no file '/home/tarcisioe/.local/share/nvim/rocks/share/lua/5.1/luarocks/core/path.lua'
        no file '/home/tarcisioe/.local/share/nvim/rocks/share/lua/5.1/luarocks/core/path/init.lua'
        no file '/usr/share/lua/5.1/init.lua'
        no file '/home/tarcisioe/.luarocks/share/lua/5.1/luarocks/core/path.lua'
        no file '/home/tarcisioe/.luarocks/share/lua/5.1/luarocks/core/path/init.lua'
        no file './luarocks/core/path.so'
        no file '/usr/local/lib/lua/5.1/luarocks/core/path.so'
        no file '/usr/lib/lua/5.1/luarocks/core/path.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file '/home/tarcisioe/.local/share/nvim/rocks/lib/lua/5.1/luarocks/core/path.so'
        no file '/home/tarcisioe/.local/share/nvim/rocks/lib64/lua/5.1/luarocks/core/path.so'
        no file '/home/tarcisioe/.luarocks/lib/lua/5.1/luarocks/core/path.so'
        no file './luarocks.so'
        no file '/usr/local/lib/lua/5.1/luarocks.so'
        no file '/usr/lib/lua/5.1/luarocks.so'
        no file '/usr/local/lib/lua/5.1/loadall.so'
        no file '/home/tarcisioe/.local/share/nvim/rocks/lib/lua/5.1/luarocks.so'
        no file '/home/tarcisioe/.local/share/nvim/rocks/lib64/lua/5.1/luarocks.so'
        no file '/home/tarcisioe/.luarocks/lib/lua/5.1/luarocks.so'

I have checked the code in my config that adds everything to the runtime path and everything seems ok. Also commented out all my plugins to ensure nothing is being loaded and no config is being called. Happens with a fresh install (rm -r ~/.local/nvim/* followed by luarocks --lua-version=5.1 --tree /home/tarcisioe/.local/share/nvim/rocks --server='https://nvim-neorocks.github.io/rocks-binaries/' install rocks.nvim)

I have attempted to install luarocks with lua-version=5.1 inside ~/.local/share/nvim/rocks but then things got even weirder with coroutine/callback errors from nio so I don't think it was a good idea :sweat_smile:

Edit: I looked at #247 but I'm on 2.21, and the code from the PR that closed that issue is present on my installation.

tarcisioe commented 1 month ago

I think I somewhat get what is happening:

My luarocks binary comes from the luarocks package from Arch. That is a Lua 5.4 package. I thus tried doing sudo luarocks install --lua-version=5.1 luarocks (knowing that would break the luarocks package). That did in fact fix the issue, however I of course uninstalled it and reinstalled the system luarocks package.

But what puzzles me is that if I run lua =vim.system({ "luarocks", "--lua-version=5.1", "which", "luarocks.core.path" }):wait().stdout:match("(%S+)/luarocks /core/path.lua"), which is what rocks.nvim is adding to the path, it outputs /usr/share/lua/5.4, which isn't being searched (and I believe it most likely shouldn't be, in fact).

It seems that luarocks modules should be acessible from elsewhere for rocks.nvim, maybe on its own tree, but I'm unsure how to do that. My previous attempt to do this failed, in fact, with a rather puzzling effect. This is what I get if I install luarocks to ~/.local/share/nvim/rocks:

Error executing vim.schedule lua callback: ...sioe/.local/share/nvim/rocks/share/lua/5.1/nio/tasks.lua:95: Async task fa
iled without callback: The coroutine failed with this message:                                                          
...isioe/.local/share/nvim/rocks/share/lua/5.1/nio/init.lua:119: The coroutine failed with this message:                
...oe/.local/share/nvim/rocks/share/lua/5.1/nio/control.lua:145: /usr/bin/lua5.1: ...ib/luarocks/rocks-5.1/luarocks/3.11
.0-1/bin/luarocks:6: loop or previous error loading module 'luarocks.loader'                                            
stack traceback:                                                                                                        
        [C]: in function 'require'                                                                                      
        ...ib/luarocks/rocks-5.1/luarocks/3.11.0-1/bin/luarocks:6: in main chunk                                        
        [C]: ?                                                                                                          

stack traceback:                                                                                                        
        [C]: in function 'error'                                                                                        
        ...oe/.local/share/nvim/rocks/share/lua/5.1/nio/control.lua:145: in function 'wait'                             
        ...oe/.local/share/nvim/rocks/share/lua/5.1/rocks/state.lua:43: in function 'installed_rocks'                   
        ...oe/.local/share/nvim/rocks/share/lua/5.1/rocks/state.lua:136: in function 'query_removable_rocks'            
        ...oe/.local/share/nvim/rocks/share/lua/5.1/rocks/cache.lua:71: in function <...oe/.local/share/nvim/rocks/share
/lua/5.1/rocks/cache.lua:67>                                                                                            
stack traceback:                                                                                                        
        [C]: in function 'error'                                                                                        
        ...isioe/.local/share/nvim/rocks/share/lua/5.1/nio/init.lua:119: in function 'gather'                           
        .../luarocks/rocks-5.1/rocks.nvim/2.21.0-1/plugin/rocks.lua:56: in function <.../luarocks/rocks-5.1/rocks.nvim/2
.21.0-1/plugin/rocks.lua:54>                                                                                            
stack traceback:                                                                                                        
        [C]: in function 'error'                                                                                        
        ...sioe/.local/share/nvim/rocks/share/lua/5.1/nio/tasks.lua:95: in function 'close_task'                        
        ...sioe/.local/share/nvim/rocks/share/lua/5.1/nio/tasks.lua:117: in function 'cb'                               
        ...sioe/.local/share/nvim/rocks/share/lua/5.1/nio/tasks.lua:183: in function 'waiter'                           
        ...oe/.local/share/nvim/rocks/share/lua/5.1/nio/control.lua:57: in function 'set'                               
        ...isioe/.local/share/nvim/rocks/share/lua/5.1/nio/init.lua:105: in function 'cb'                               
        ...sioe/.local/share/nvim/rocks/share/lua/5.1/nio/tasks.lua:93: in function 'close_task'                        
        ...sioe/.local/share/nvim/rocks/share/lua/5.1/nio/tasks.lua:117: in function 'cb'                               
        ...sioe/.local/share/nvim/rocks/share/lua/5.1/nio/tasks.lua:183: in function 'waiter'                           
        ...oe/.local/share/nvim/rocks/share/lua/5.1/nio/control.lua:116: in function 'wake'                             
        ...oe/.local/share/nvim/rocks/share/lua/5.1/nio/control.lua:137: in function 'set_error'                        
        ...oe/.local/share/nvim/rocks/share/lua/5.1/rocks/state.lua:37: in function 'on_exit'                           
        ....local/share/nvim/rocks/share/lua/5.1/rocks/luarocks.lua:67: in function ''                                  
        vim/_editor.lua: in function <vim/_editor.lua:0>     
mrcjkb commented 1 month ago

Hey :wave:

thanks for reporting. I'll add a fix that only calls the loader for luarocks lua=5.1 installations.