fix(rocks): if installing with luarocks (binaries) fails, then build from source. Fixes #1563

This commit is contained in:
Folke Lemaitre 2024-06-27 11:33:11 +02:00
parent e02c5b1b57
commit 82276321f5
No known key found for this signature in database
GPG key ID: 41F8B1FBACAE2040
2 changed files with 35 additions and 2 deletions

View file

@ -101,6 +101,7 @@ function M.check(opts)
return ok
end
---@async
---@param task LazyTask
function M.build(task)
if
@ -163,7 +164,7 @@ function M.build(task)
)
local root = Config.options.rocks.root .. "/" .. task.plugin.name
task:spawn(luarocks, {
local ok = task:spawn(luarocks, {
args = {
"--tree",
root,
@ -181,6 +182,30 @@ function M.build(task)
cwd = task.plugin.dir,
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
---@param rockspec RockSpec