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

Processing of luarocks fails when cwd is rocks or plugin directory #312

Open
salkin-mada opened this issue May 3, 2024 · 18 comments
Open
Assignees

Comments

@salkin-mada
Copy link

I just stumbled upon this:
cd ~/.local/share/nvim/rocks/share/lua/5.1/rocks
and then running neovim throws:

Error detected while processing /Users/salkin/.local/share/nvim/rocks/lib/luarocks/rocks-5.1/rocks-git.nvim/1.5.0-1/plugin/rocks-git.lua:                                  
E5113: Error while calling lua chunk: ./fzy.lua:21: loop or previous error loading module 'fzy'                                                                            
stack traceback:                                                                                                                                                           
        [C]: in function 'require'                                                                                                                                         
        ./fzy.lua:21: in main chunk                                                                                                                                        
        [C]: in function 'require'                                                                                                                                         
        ...lkin/.local/share/nvim/rocks/share/lua/5.1/rocks/fzy.lua:21: in main chunk                                                                                      
        [C]: in function 'require'                                                                                                                                         
        ....local/share/nvim/rocks/share/lua/5.1/rocks/commands.lua:53: in main chunk                                                                                      
        [C]: in function 'require'                                                                                                                                         
        ....local/share/nvim/rocks/share/lua/5.1/rocks/api/init.lua:27: in main chunk                                                                                      
        [C]: in function 'require'                                                                                                                                         
        ...ks/rocks-5.1/rocks-git.nvim/1.5.0-1/plugin/rocks-git.lua:4: in main chunk                                                                                       
Error detected while processing /Users/salkin/.local/share/nvim/rocks/lib/luarocks/rocks-5.1/rocks-treesitter.nvim/scm-1/plugin/rocks-treesitter.lua:                      
E5113: Error while calling lua chunk: ...are/nvim/rocks/share/lua/5.1/rocks_treesitter/config.lua:14: loop or previous error loading module 'rocks.api'                    
stack traceback:                                                                                                                                                           
        [C]: in function 'require'                                                                                                                                         
        ...are/nvim/rocks/share/lua/5.1/rocks_treesitter/config.lua:14: in main chunk                                                                                      
        [C]: in function 'require'                                                                                                                                         
        .../rocks-treesitter.nvim/scm-1/plugin/rocks-treesitter.lua:5: in main chunk                                                                                       
Error detected while processing /Users/salkin/.local/share/nvim/rocks/lib/luarocks/rocks-5.1/rocks.nvim/2.26.0-1/plugin/rocks.lua:                                         
E5113: Error while calling lua chunk: .../luarocks/rocks-5.1/rocks.nvim/2.26.0-1/plugin/rocks.lua:33: loop or previous error loading module 'rocks.commands'               
stack traceback:                                                                                                                                                           
        [C]: in function 'require'                                                                                                                                         
        .../luarocks/rocks-5.1/rocks.nvim/2.26.0-1/plugin/rocks.lua:33: in main chunk

Then doing a cd .. to get out of the rocks folder into ~/.local/share/nvim/rocks/share/lua/5.1
Run neovim from that cwd -> it is fine. All good. I can even navigate with netrw/fzf to the rocks folder and open/edit files. All good.

So rocks.nvim fails if cwd is the rocks path it self?

NVIM v0.10.0-dev-3045+gefaf37a2b
Build type: RelWithDebInfo
LuaJIT 2.1.1713484068
Run "nvim -V1 -v" for more info

@mrcjkb
Copy link
Member

mrcjkb commented May 3, 2024

🤔 I suppose it could be a bug in the luarocks loader?
Does it happen if you set enable_luarocks_loader = false in your vim.g.rocks_nvim config?

@salkin-mada
Copy link
Author

Can you reproduce?

I added:

-- Lua Rocks --
local rocks_config = {
    rocks_path = vim.env.HOME .. "/.local/share/nvim/rocks",
    luarocks_binary = vim.env.HOME .. "/.local/share/nvim/rocks/bin/luarocks",
	enable_luarocks_loader = false
}

vim.g.rocks_nvim = rocks_config

and did the same cd and nvim as mentioned before. Same error

@salkin-mada
Copy link
Author

A bug in rocks-git maybe?

@mrcjkb
Copy link
Member

mrcjkb commented May 4, 2024

Can you reproduce?

No, because I have rocks.nvim installed with nix.
@vhyrro are you able to reproduce this?

@boydkelly
Copy link

boydkelly commented May 8, 2024

I also was just migrating my config files (from lazy) and had a lot of issues with this the last few days. My setup files are in the plugin directory. I finally figured out that if that is my cwd then I get the above errors for a good portion (but not all) of my setup files. I haven`t investigated that further as my workaround was just to back out of the plugin before editing any files there. Not sure what other info I might be able to provide.... (I am super happy with nvim-rocks!!!) Thanks!!

sample errors if cwd is nvim-rocks/plugin(otherwise no errors):

Error detected while processing /var/home/bkelly/.config/nvim-rocks/plugin/conform.lua:
E5113: Error while calling lua chunk: ./conform.lua:43: loop or previous error loading module 'conform'
stack traceback:
        [C]: in function 'require'
        ./conform.lua:43: in main chunk
        [C]: in function 'require'
        /var/home/bkelly/.config/nvim-rocks/plugin/conform.lua:43: in main chunk
Error detected while processing /var/home/bkelly/.config/nvim-rocks/plugin/dressing.lua:
E5113: Error while calling lua chunk: ./dressing.lua:36: loop or previous error loading module 'dressing'
stack traceback:
        [C]: in function 'require'
        ./dressing.lua:36: in main chunk
        [C]: in function 'require'
        /var/home/bkelly/.config/nvim-rocks/plugin/dressing.lua:36: in main chunk
Error detected while processing /var/home/bkelly/.config/nvim-rocks/plugin/fidget.lua:
E5113: Error while calling lua chunk: ./fidget.lua:1: loop or previous error loading module 'fidget'
stack traceback:
        [C]: in function 'require'
        ./fidget.lua:1: in main chunk
        [C]: in function 'require'
        /var/home/bkelly/.config/nvim-rocks/plugin/fidget.lua:1: in main chunk
Error detected while processing /var/home/bkelly/.config/nvim-rocks/plugin/fzf-lua.lua:
E5113: Error while calling lua chunk: ./fzf-lua.lua:1: loop or previous error loading module 'fzf-lua'
stack traceback:
        [C]: in function 'require'
        ./fzf-lua.lua:1: in main chunk
        [C]: in function 'require'
        /var/home/bkelly/.config/nvim-rocks/plugin/fzf-lua.lua:1: in main chunk

@mrcjkb
Copy link
Member

mrcjkb commented May 8, 2024

@boydkelly thanks for the input and nice words.
I just set up a minimal plain (non-nix) rocks.nvim installation (with NVIM_APPNAME set to rocksvim, no plugins installed),
and tried the following:

cd ~/.config/rocksvim
mkdir plugin
cd plugin
nvim dressing.lua

and did not encounter any errors.
Do you have a link to your rocks.toml so that I can try and bisect it?

@salkin-mada
Copy link
Author

salkin-mada commented May 9, 2024

@boydkelly what system are you on?
I am having trouble reproducing this on Arch in any of the mentioned paths, but on the macOS ~/.local/share/nvim/rocks/share/lua/5.1/rocks is fail.
Also I cant reproduce the error in my plugins folder on any of the systems -> ~/.config/nvim/lua/plugins/

@mrcjkb
Copy link
Member

mrcjkb commented May 9, 2024

@boydkelly what system are you on? I am having trouble reproducing this on Arch in any of the mentioned paths, but on the macOS ~/.local/share/nvim/rocks/share/lua/5.1/rocks is fail. Also I cant reproduce the error in my plugins folder on any of the systems -> ~/.config/nvim/lua/plugins/

Ooh, could it be a path with spaces in it or something? 🤔

@boydkelly
Copy link

boydkelly commented May 10, 2024

@mrcjkb So strange! I am in a Fedora 40 container. I did have luarocks installed in the container and removed that but still the same issue. Here is the complete repo. (Its working mostly, although a work in progress moving from lazy)
https://gitlab.com/boydkelly/nvim-rocks.git

I am also using NVIM_APPNAME=nvim-rocks, and was wondering if that somehow might be a problem? I will try to move it all to ./config/nvim and see if that makes any difference. For now I just have to not edit any of the files in plugin.

My config does seem to be mostly working otherwise. Couple of issues that I will report later if I don't solve.

Just an fyi, I don't have to edit a file in plugin. If plugin is my cwd, then just running nvim-rocks will output an ton of those errors, but if i start nvim-rocks anywhere else it works fine.

@mrcjkb
Copy link
Member

mrcjkb commented May 11, 2024

Thanks. I'll see if I can reproduce it with your config later 👀

@kflak
Copy link

kflak commented May 11, 2024

Running into a similar issue here on my Arch Linux install after the last Rocks update. I can edit files just fine from anywhere but my plugin config folder, which in my case is ~/.config/nvim/lua/rocks-plugs

Errors:

Error detected while processing /home/kf/.local/share/nvim/rocks/lib/luarocks/rocks-5.1/luasnip/2.3.0-1/plugin/luasnip.lua:
E5113: Error while calling lua chunk: ....local/share/nvim/rocks/share/lua/5.1/luasnip/config.lua:100: attempt to index a boolean value
stack traceback:
        ....local/share/nvim/rocks/share/lua/5.1/luasnip/config.lua:100: in function '_setup'
        ...ib/luarocks/rocks-5.1/luasnip/2.3.0-1/plugin/luasnip.lua:79: in main chunk

and

Vim:E5113: Error while calling lua chunk: ....local/share/nvim/rocks/share/lua/5.1/luasnip/config.lua:100: attempt to index a boolean value
stack traceback:                                                                                                                                  
^I....local/share/nvim/rocks/share/lua/5.1/luasnip/config.lua:100: in function '_setup'                                                           
^I...ib/luarocks/rocks-5.1/luasnip/2.3.0-1/plugin/luasnip.lua:79: in main chunk                                                                   
^I[C]: at 0x61d5a6b8f110                                                                                                                          
^I[C]: in function 'pcall'                                                                                                                        
^I.../.local/share/nvim/rocks/share/lua/5.1/rocks/runtime.lua:35: in function 'packadd'                                                           
^I.../.local/share/nvim/rocks/share/lua/5.1/rocks/runtime.lua:61: in function 'source_start_plugins'                                              
^I.../luarocks/rocks-5.1/rocks.nvim/2.27.1-1/plugin/rocks.lua:59: in main chunk 

My dotfiles are here, hopefully they can help you replicate.

@mrcjkb mrcjkb self-assigned this May 11, 2024
@mrcjkb
Copy link
Member

mrcjkb commented May 11, 2024

@boydkelly I just installed all of your plugins with NVIM_APPNAME = nvim-rocks.

  • I got a stack overflow error when starting (no matter what the cwd). This was caused by hotpot.nvim, so I removed it.
    If you are facing the same error, you could probably work around it by setting vim.g.rocks_nvim.enable_luarocks_loader to false. This is either a bug in the hotpot.nvim loader or in the luarocks loader.
  • I was not able to reproduce the behaviour 😞

@kflak the symptom seems related, but the error message looks different. It seems to be something thrown by luasnip. What makes it even stranger is that there's nothing but a parenthesis at the specified location (config.lua, line 100) at the v2.3.0 tag.
There's a call to require("luasnip") at line 99. Maybe there's something funky going on with the luarocks loader and that is returning a boolean instead of a module?
But others have not been able to work around the issue by setting the enable_luarocks_loader config to false.

@mrcjkb
Copy link
Member

mrcjkb commented May 12, 2024

@kflak I just tried with you config too, and couldn't reproduce it either.
Maybe somehow your installations (rocks or plugins) got corrupted? You could try cleaning and reinstalling rocks.nvim and/or the affected plugins.

@kflak
Copy link

kflak commented May 12, 2024

@kflak I just tried with you config too, and couldn't reproduce it either. Maybe somehow your installations (rocks or plugins) got corrupted? You could try cleaning and reinstalling rocks.nvim and/or the affected plugins.

OK, I've managed to narrow it down to luasnip. The error doesn't happen when I install it with rocks-git, so there's something smelly with the rocks package, I suppose...

@mrcjkb
Copy link
Member

mrcjkb commented May 12, 2024

@kflak I just tried with you config too, and couldn't reproduce it either. Maybe somehow your installations (rocks or plugins) got corrupted? You could try cleaning and reinstalling rocks.nvim and/or the affected plugins.

OK, I've managed to narrow it down to luasnip. The error doesn't happen when I install it with rocks-git, so there's something smelly with the rocks package, I suppose...

Maybe the bug was fixed but not released yet?

@kflak
Copy link

kflak commented May 12, 2024

@kflak I just tried with you config too, and couldn't reproduce it either. Maybe somehow your installations (rocks or plugins) got corrupted? You could try cleaning and reinstalling rocks.nvim and/or the affected plugins.

OK, I've managed to narrow it down to luasnip. The error doesn't happen when I install it with rocks-git, so there's something smelly with the rocks package, I suppose...

Maybe the bug was fixed but not released yet?

Kind of doubt it, there hasn't been a commit there since 14 April, and I didn't have this problem before now...

@mrcjkb
Copy link
Member

mrcjkb commented May 12, 2024

Kind of doubt it, there hasn't been a commit there since 14 April, and I didn't have this problem before now...

I'm seeing commits on April 16, 21 and 30.

@mrcjkb mrcjkb changed the title Processing of luarocks fails Processing of luarocks fails when cwd is rocks or plugin directory May 12, 2024
@boydkelly
Copy link

boydkelly commented May 26, 2024

Just an update here. I made a basic install with only:

[rocks]

# List of Neovim plugins to install alongside their versions.
# If the plugin name contains a dot then you must add quotes to the key name!
[plugins]
"rocks.nvim" = "2.29.0"
"rocks-git.nvim" = "1.5.1"
"rocks-treesitter.nvim" = "scm"
tree-sitter-vimdoc = "scm"
tree-sitter-lua = "scm"
"oil.nvim" = "2.9.0"

https://gitlab.com/boydkelly/nvim-nb.git

I still get the following error starting neovim if my cwd is plugin:

Error detected while processing /var/home/bkelly/.config/nvim-nb/plugin/oil.lua:
E5113: Error while calling lua chunk: ./oil.lua:1: loop or previous error loading module 'oil'
stack traceback:
        [C]: in function 'require'
        ./oil.lua:1: in main chunk
        [C]: in function 'require'
        /var/home/bkelly/.config/nvim-nb/plugin/oil.lua:1: in main chunk

I get this same error in both an Arch and Fedora container, as well as on a Fedora workstation. Albeit both the Arch and Fedora containers are toolboxes and share the same bash profile etc. However I don't see anything in PATH or environment that could affect this. The Fedora container contains a bunch of development stuff, but the Arch install is only the base container image + neovim.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants