mirror of https://github.com/folke/lazy.nvim.git
fix(rocks): if installing with luarocks (binaries) fails, then build from source. Fixes #1563
This commit is contained in:
parent
e02c5b1b57
commit
82276321f5
|
@ -37,7 +37,7 @@ function Task.new(plugin, name, task, opts)
|
||||||
local self = setmetatable({}, { __index = Task })
|
local self = setmetatable({}, { __index = Task })
|
||||||
self._opts = opts or {}
|
self._opts = opts or {}
|
||||||
self._log = {}
|
self._log = {}
|
||||||
self._level = vim.log.levels.TRACE
|
self:set_level()
|
||||||
self.plugin = plugin
|
self.plugin = plugin
|
||||||
self.name = name
|
self.name = name
|
||||||
---@param other LazyTask
|
---@param other LazyTask
|
||||||
|
@ -95,6 +95,11 @@ function Task:has_warnings()
|
||||||
return self._level >= vim.log.levels.WARN
|
return self._level >= vim.log.levels.WARN
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@param level? number
|
||||||
|
function Task:set_level(level)
|
||||||
|
self._level = level or vim.log.levels.TRACE
|
||||||
|
end
|
||||||
|
|
||||||
---@private
|
---@private
|
||||||
---@param task LazyTaskFn
|
---@param task LazyTaskFn
|
||||||
function Task:_start(task)
|
function Task:_start(task)
|
||||||
|
@ -218,6 +223,7 @@ function Task:spawn(cmd, opts)
|
||||||
end
|
end
|
||||||
|
|
||||||
local running = true
|
local running = true
|
||||||
|
local ret = true
|
||||||
---@param output string
|
---@param output string
|
||||||
function opts.on_exit(ok, output)
|
function opts.on_exit(ok, output)
|
||||||
if not headless then
|
if not headless then
|
||||||
|
@ -226,6 +232,7 @@ function Task:spawn(cmd, opts)
|
||||||
if on_exit then
|
if on_exit then
|
||||||
pcall(on_exit, ok, output)
|
pcall(on_exit, ok, output)
|
||||||
end
|
end
|
||||||
|
ret = ok
|
||||||
running = false
|
running = false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -240,6 +247,7 @@ function Task:spawn(cmd, opts)
|
||||||
while running do
|
while running do
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
end
|
end
|
||||||
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
function Task:prefix()
|
function Task:prefix()
|
||||||
|
|
|
@ -101,6 +101,7 @@ function M.check(opts)
|
||||||
return ok
|
return ok
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---@async
|
||||||
---@param task LazyTask
|
---@param task LazyTask
|
||||||
function M.build(task)
|
function M.build(task)
|
||||||
if
|
if
|
||||||
|
@ -163,7 +164,7 @@ function M.build(task)
|
||||||
)
|
)
|
||||||
|
|
||||||
local root = Config.options.rocks.root .. "/" .. task.plugin.name
|
local root = Config.options.rocks.root .. "/" .. task.plugin.name
|
||||||
task:spawn(luarocks, {
|
local ok = task:spawn(luarocks, {
|
||||||
args = {
|
args = {
|
||||||
"--tree",
|
"--tree",
|
||||||
root,
|
root,
|
||||||
|
@ -181,6 +182,30 @@ function M.build(task)
|
||||||
cwd = task.plugin.dir,
|
cwd = task.plugin.dir,
|
||||||
env = env,
|
env = env,
|
||||||
})
|
})
|
||||||
|
|
||||||
|
if ok then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
task:warn("Failed installing " .. rockspec.package .. " with `luarocks`.\nTrying to build from source.")
|
||||||
|
|
||||||
|
-- install failed, so try building from source
|
||||||
|
task:set_level() -- reset level
|
||||||
|
task:spawn(luarocks, {
|
||||||
|
args = {
|
||||||
|
"--tree",
|
||||||
|
root,
|
||||||
|
"--dev",
|
||||||
|
"--lua-version",
|
||||||
|
"5.1",
|
||||||
|
"make",
|
||||||
|
"--force-fast",
|
||||||
|
"--deps-mode",
|
||||||
|
"one",
|
||||||
|
},
|
||||||
|
cwd = task.plugin.dir,
|
||||||
|
env = env,
|
||||||
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
---@param rockspec RockSpec
|
---@param rockspec RockSpec
|
||||||
|
|
Loading…
Reference in New Issue