diff --git a/lua/rocks/adapter.lua b/lua/rocks/adapter.lua index e74ffa9..c1c8a2a 100644 --- a/lua/rocks/adapter.lua +++ b/lua/rocks/adapter.lua @@ -138,6 +138,10 @@ end ---@param rock RockSpec | Rock ---@return boolean created function adapter.init_site_symlink_sync(rock) + if not rock.version then + log.info("Cannot init site symlink without rock version") + return false + end local rock_dir = get_rock_dir(rock) local handle = vim.uv.fs_scandir(rock_dir) while handle do diff --git a/lua/rocks/operations/helpers/init.lua b/lua/rocks/operations/helpers/init.lua index e21f80e..20bb99f 100644 --- a/lua/rocks/operations/helpers/init.lua +++ b/lua/rocks/operations/helpers/init.lua @@ -154,14 +154,16 @@ function helpers.dynamic_load(rock_spec) end nio.run(function() vim.schedule(function() - if rock_spec.opt then - -- Add rock to the rtp, but don't source any scripts - log.trace(("Adding %s to the runtimepath"):format(rock_spec.name)) - runtime.packadd(rock_spec, { bang = true }) - else - log.trace(("Sourcing %s"):format(rock_spec.name)) - runtime.packadd(rock_spec) - end + pcall(function() + if rock_spec.opt then + -- Add rock to the rtp, but don't source any scripts + log.trace(("Adding %s to the runtimepath"):format(rock_spec.name)) + runtime.packadd(rock_spec, { bang = true }) + else + log.trace(("Sourcing %s"):format(rock_spec.name)) + runtime.packadd(rock_spec) + end + end) future.set(true) end) end) diff --git a/lua/rocks/runtime.lua b/lua/rocks/runtime.lua index 70d0066..bd5e8d6 100644 --- a/lua/rocks/runtime.lua +++ b/lua/rocks/runtime.lua @@ -38,7 +38,11 @@ function runtime.packadd(rock_spec, opts) opts = vim.tbl_deep_extend("force", { bang = false, }, opts or {}) - if not adapter.has_site_symlink(rock_spec) and not adapter.init_site_symlink_sync(rock_spec) then + if + rock_spec.version + and not adapter.has_site_symlink(rock_spec) + and not adapter.init_site_symlink_sync(rock_spec) + then log.warn(("Rock %s does not appear to be installed."):format(rock_spec.name)) return false end