nvim-neorocks / rocks.nvim

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

rocks-binaries should not be used on musl systems (e.g. Alpine) #487

Closed vimproved closed 2 weeks ago

vimproved commented 1 month ago

On systems using musl, binaries from rocks-binaries will not work by default, and there's no way to force luarocks to compile from source at the current moment (e.g. a config option). As an example, if you set up a barebones rocks.nvim installation on a musl system and then run :Rocks install tree-sitter-bash, you will end up with a binary linked against glibc that will therefor fail to load:

vi@virtuoso ~ % cd .local/share/nvim/rocks/lib/lua/5.1/parser 
vi@virtuoso parser % lddtree bash.so 
bash.so => ./bash.so (interpreter => none)
    libc.so.6 => not found

Or for another example, if you reinstall or update toml-edit through rocks.nvim after bootstrapping, then it will attempt to use the binary linked against glibc and throw this error on startup:

Error detected while processing /home/vi/.local/share/nvim/rocks/lib/luarocks/rocks-5.1/rocks.nvim/2.36.1-1/plugin/rocks.lua:
E5113: Error while calling lua chunk: ...local/share/nvim/rocks/rocks_rtp/lua/luarocks/loader.lua:104: error loading module 'toml_edit' from file '/home/vi/.local/share/nvim/rocks/lib/lua/5.1/toml_edit.so':
        Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /home/vi/.local/share/nvim/rocks/lib/lua/5.1/toml_edit.so)
stack traceback:
        [C]: in function 'a_loader'
        ...local/share/nvim/rocks/rocks_rtp/lua/luarocks/loader.lua:104: in function <...local/share/nvim/rocks/rocks_rtp/lua/luarocks/loader.lua:101>
        [C]: in function 'require'
        ...share/nvim/rocks/share/lua/5.1/rocks/config/internal.lua:74: in function 'get_rocks_toml'
        ...share/nvim/rocks/share/lua/5.1/rocks/config/internal.lua:113: in function 'get_user_rocks'
        .../luarocks/rocks-5.1/rocks.nvim/2.36.1-1/plugin/rocks.lua:61: in main chunk
vimproved commented 1 month ago

A workaround for this seems to be setting arch = "linux-musl-x86_64" in luarocks_config to avoid grabbing linux-x86_64 binaries, but I'm not sure if this has other side effects.

mrcjkb commented 1 month ago

Thanks for reporting.

I think for now the best option is to check the architecture in rocks.nvim and only enable rocks-binaries for the supported architectures.

I'll look into that.

mrcjkb commented 1 month ago

@vimproved what's the output of vim.uv.os_uname() on your system?

vimproved commented 1 month ago

@vimproved what's the output of vim.uv.os_uname() on your system?

{
  machine = "x86_64",
  release = "6.10.2-gentoo",
  sysname = "Linux",
  version = "#2 SMP PREEMPT_DYNAMIC Mon Jul 29 17:49:13 UTC 2024"
}
mrcjkb commented 1 month ago

Thanks. You'll be able to disable the binary servers when #494 has been merged and released.