rktjmp/hotpot.nvim

Rocks.nvim install - checkhealth Hotpot Module Searcher index mismatch error

Closed this issue · 3 comments

Fresh install into clean nvim instance using Rocks.nvim results in error when running checkhealth. As far as I can tell does not cause any issues with hotpot besides the error itself?

hotpot: require("hotpot.health").check()

Hotpot Cache Data ~
- Cache root path: /home/ghost/.cache/hotpot/hotpot
- Cache size: 1 files, 4kb

Hotpot Log ~
- Log path: /home/ghost/.local/state/hotpot/hotpot.log
- Log size: 0

Hotpot Module Searcher ~
- ERROR package.loader index: 3, requires: 2

This happens on my main config, but I started a new NVIM_APPNAME instance to reproduce this with fresh/minimal config as shown below:

init.lua
do
  local install_location = vim.fs.joinpath(vim.fn.stdpath("data"), "rocks")
  local rocks_config = { ["rocks-path"] = vim.fs.normalize(install_location) }
  vim.g.rocks_nvim = rocks_config
  local luarocks_path = {
    vim.fs.joinpath(rocks_config["rocks-path"], "share", "lua", "5.1", "?.lua"),
    vim.fs.joinpath(rocks_config["rocks-path"], "share", "lua", "5.1", "?", "init.lua"),
  }
  package.path = (package.path .. ";" .. table.concat(luarocks_path, ";"))
  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"),
  }
  package.cpath = (package.cpath .. ";" .. table.concat(luarocks_cpath, ";"))
  vim.opt.runtimepath:append(
    vim.fs.joinpath(rocks_config["rocks-path"], "lib", "luarocks", "rocks-5.1", "rocks.nvim", "*")
  )
end

if not pcall(require, "rocks") then
  local rocks_location = vim.fs.joinpath(vim.fn.stdpath("cache"), "rocks.nvim")
  if not vim.uv.fs_stat(rocks_location) then
    vim.fn.system({
      "git",
      "clone",
      "--filter=blob:none",
      "https://github.com/nvim-neorocks/rocks.nvim",
      rocks_location,
    })
  else
  end
  assert((vim.v.shell_error == 0), "rocks.nvim installation failed. Try exiting and re-entering Neovim!")
  vim.cmd.source(vim.fs.joinpath(rocks_location, "bootstrap.lua"))
  vim.fn.delete(rocks_location, "rf")
else
end

require("hotpot")

rocks.toml
[rocks]

[plugins]
"rocks.nvim" = "2.40.1"
"hotpot.nvim" = "0.14.5"

Yeah, from what I can recall, this is a know "issue" because rocks calls require luarocks.loader, which always installs itself as index 1 in the searchers. Then depending on when hotpot was required/setup, we might install ourselves at 2, or have been pushed back to 3.

I have intended to improve that message.

The issue was I would rather check if luarocks was injected vs rocks.nvim specifically but I can't check if the functions ahead of us == the luarocks loader is without calling require luarocks.loader to get the function,which installs the loader and the user might not want that.

I could copy the table and put it back after checking but I wasn't sure of any other side effects luarocks might do, it felt brittle.

e: I can check package.loaded[luarocks.loader] actually...

This should be improved in 0.14.6.

@rktjmp Appreciate the insight and feedback as well as your time and efforts in sharing this phenomenal project.