nvim-neorocks / rocks-config.nvim

Allow rocks.nvim to help configure your plugins.
GNU General Public License v3.0
55 stars 2 forks source link

Failed installing dependency: https://luarocks.org/toml-edit-0.4.1-1.src.rock - Build error: 'cargo' is not installed. #52

Closed teto closed 1 month ago

teto commented 1 month ago

following up on a comment from @mrcjkb to use the latest version of rocks-config rather than nixpkgs's one, I tried Rocks install rocks-config.nvim and was greeted with:

ERROR | 2024-06-28 14:07:16 | ...myNeovimPackages/start/rocks.nvim/lua/rocks/luarocks.lua:64 | luarocks CLI FAILED
ERROR | 2024-06-28 14:07:16 | ...myNeovimPackages/start/rocks.nvim/lua/rocks/luarocks.lua:65 | 
Error: Failed installing dependency: https://luarocks.org/rocks.nvim-2.32.0-1.src.rock - Failed installing dependency: https://luarocks.org/toml-edit-0.4.1-1.src.rock - Build error: 'cargo' is not installed.
This rock is written in Rust: make sure you have a Rust
development environment installed and try again.

ERROR | 2024-06-28 14:07:16 | ...ckages/start/rocks.nvim/lua/rocks/operations/helpers.lua:69 | Failed to install rocks-config.nvim

I feel lied to https://github.com/nvim-neorocks/rocks-config.nvim?tab=readme-ov-file#hammer-installation xD

Providing cargo indeed fixes it. Maybe it's a problem of me not being able to install binaries from a .rock. Nevertheless, we should mention the fallback method just in case as there are scenarii where one might want to install from source.

teto commented 1 month ago

note that even with cargo, I get

Error executing vim.schedule lua callback: ...r/pack/myNeovimPackages/start/nvim-nio/lua/nio/tasks.lua:100: Async task failed without callback: The coroutine failed with this message:                                                                         
...pack/myNeovimPackages/start/nvim-nio/lua/nio/control.lua:145: /usr/bin/env: ‘lua’: No such file or directory                                                                                                                                                 

stack traceback:                                                                                              
        [C]: in function 'error'                                                                                                                   
        ...pack/myNeovimPackages/start/nvim-nio/lua/nio/control.lua:145: in function 'wait'                                                          
        ...ck/myNeovimPackages/start/rocks.nvim/lua/rocks/state.lua:43: in function 'installed_rocks'                                               
        .../myNeovimPackages/start/rocks.nvim/lua/rocks/adapter.lua:104: in function 'init_site_symlinks'                                       
        .../myNeovimPackages/start/rocks.nvim/lua/rocks/adapter.lua:133: in function 'init_site_links'                                         
        .../myNeovimPackages/start/rocks.nvim/lua/rocks/adapter.lua:138: in function 'init'                                       
        ...1-rocks.nvim-2.31.3-1-unstable-2.31.3-1/plugin/rocks.lua:56: in function <...1-rocks.nvim-2.31.3-1-unstable-2.31.3-1/plugin/rocks.lua:55> 

or

ERROR | 2024-06-28 14:23:14 | ...myNeovimPackages/start/rocks.nvim/lua/rocks/luarocks.lua:64 | luarocks CLI FAILED
ERROR | 2024-06-28 14:23:14 | ...myNeovimPackages/start/rocks.nvim/lua/rocks/luarocks.lua:65 | /usr/bin/env: ‘lua’: No such file or directory

ERROR | 2024-06-28 14:23:14 | ...ckages/start/rocks.nvim/lua/rocks/operations/helpers.lua:69 | Failed to install rocks-config.nvim

wonder if we should provide nlua or do some other tricks

teto commented 1 month ago

I think the #!/usr/bin/env lua comes from src/bin/luarocks so there might be something wrong with the nix packaging that doesn't wrap luarocks executable (I am not 100% convinced it is desirable yet).

linking https://github.com/nvim-neorocks/rocks.nvim/discussions/229 for future me

mrcjkb commented 1 month ago

This is because you have rocks.nvim (which is a dependency of rocks-config.nvim) installed with nix.

When you use luarocks to install a rocks.nvim module, it will check if rocks.nvim is installed in the rocks_trees and will try to install it if it isn't.

For now, if you install rocks.nvim with Nix, you must install any rocks.nvim modules with Nix too. Most of them have a flake output.

I feel lied to

toml-edit is a dependency of rocks.nvim. For most users, we assume it is already installed when you try to install it with :Rocks install.

Closing, in favour of https://github.com/nvim-neorocks/rocks.nvim/issues/311

teto commented 1 month ago

checkhealth rocks shows it's using /home/teto/.local/share/nvim/rocks/bin/luarocks which must have been installed by rocks-nvim, which required rocks.nvim which requires luarocks https://github.com/nvim-neorocks/rocks.nvim/blob/704940f43c600f95a5d4a5177b918af849b3a150/rocks.nvim-scm-1.rockspec#L21 .

I removed some files from the rocks directory and then set vim.g.luarocks_binary = "/nix/store/5j4av7r2aivkgcpqfr5z9zg1p45ga760-luarocks_bootstrap-3.11.0/bin/luarocks"

checkhealth then shows - OK luarocks: found /nix/store/4lkgy51p9hn6ag56imllvi9jn3g74cdx-luajit2.1-luarocks-3.11.1-1/luarocks-3.11.1-1-rocks/luarocks/3.11.1-1/bin/luarocks 3.11.0 which still contains the /usr/bin/env lua. I wonder if the trailing 3.11.0 is wanted or if this is a bad regex. I also find it odd that it picks that luarocks instead of the one in /nix/store/4lkgy51p9hn6ag56imllvi9jn3g74cdx-luajit2.1-luarocks-3.11.1-1/bin

teto commented 1 month ago

what might be a good fix is to add nix derivations to the luarocks_config used by rocks aka

lua_version = "5.1"
rocks_trees = {
    {
      name = "rocks.nvim",
      root = "/home/teto/.local/share/nvim/rocks",
    },
    -- insert nix luarocks etc
}