nvim-neorocks / rocks.nvim

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

package.cpath update init.lua snippet is not platform independent #269

Closed zackerydev closed 1 month ago

zackerydev commented 1 month ago

Looks like something similar to this issue is happening in this library.

Thanks for all the great work on this.

https://github.com/nvim-neorocks/rocks.nvim/issues/250

mrcjkb commented 1 month ago

Hey 👋

rocks-treesitter doesn't use toml_edit directly. It uses the rocks.nvim API, which uses toml_edit. Have you tried updating rocks.nvim to the latest version?

zackerydev commented 1 month ago

@mrcjkb Yes - I have this in my rocks.toml

# This is your rocks.nvim plugins declaration file.
# Here is a small yet pretty detailed example on how to use it:
#
# [plugins]
# nvim-treesitter = "semver_version"  # e.g. "1.0.0"

# List of non-Neovim rocks.
# This includes things like `toml` or other lua packages.
[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.21.1" # rocks.nvim can also manage itself :D
"telescope.nvim" = "scm"
github-nvim-theme = "1.0.1"
"mason.nvim" = "1.10.0"
"mason-lspconfig.nvim" = "1.27.0"
cmp-nvim-lsp = "scm"
cmp-buffer = "scm"
cmp-path = "scm"
nvim-cmp = "0.0.1"
"trouble.nvim" = "2.10.0"
"lualine.nvim" = "scm"
"glow.nvim" = "0.2.0"
nvim-comment = "scm"
"conform.nvim" = "5.6.0"
"gruvbox.nvim" = "2.0.0"
nvim-treesitter = "0.9.2"
neorg = "8.4.0"
toml-edit = "0.3.6"
"oil.nvim" = "2.7.0"
"rocks-treesitter.nvim" = "scm"

And I get this stack trace when booting up:

CleanShot 2024-04-12 at 11 17 52@2x

But only when installing this rocks-treesitter.nvim plugin.

zackerydev commented 1 month ago

I did find a workaround by doing this:

cp /Users/zack.griesinger/.local/share/nvim/rocks/lib/lua/5.1/toml_edit.so /opt/homebrew/lib/lua/5.1/

This seems wrong though 🤔

mrcjkb commented 1 month ago

Ahh, I see what the issue is.

The installer script gives you a snippet to add to your init.lua, which adds luarocks native libraries in the rocks.nvim install directory to the package.cpath. On Darwin, it assumes those libraries have a .dylib extension. But in the case of toml_edit, it's .so, so lua can't find it.

As a hotfix, you can duplicate the path patterns for the cpath and set the extension to .so.

I'll create an issue to fix this. We should probably update it to make the snippet itself platform independent, in case people use the same config on multiple systems.

Very strange that this only happens when rocks-treesitter is installed though 🤔

mrcjkb commented 1 month ago

Transferring to rocks.nvim...

zackerydev commented 1 month ago

If anyone else makes it here this is the hotfix I used thanks for the suggestion @mrcjkb

-- ...
local luarocks_cpath = {
  vim.fs.joinpath(rocks_config.rocks_path, 'lib', 'lua', '5.1', '?.so'),
  vim.fs.joinpath(rocks_config.rocks_path, 'lib64', 'lua', '5.1', '?.so'),
  vim.fs.joinpath(rocks_config.rocks_path, 'lib', 'lua', '5.1', '?.dylib'),
  vim.fs.joinpath(rocks_config.rocks_path, 'lib64', 'lua', '5.1', '?.dylib'),
}
-- ...