From e0b4d1d62da535ed19a71f7f5348e00980f96e49 Mon Sep 17 00:00:00 2001 From: Felipe Guedes Date: Sun, 20 Apr 2025 22:35:06 +0100 Subject: [PATCH] fix(rockspec): adjusted luarocks executable to contain the appropriate extension on windows --- lua/lazy/pkg/rockspec.lua | 29 ++++++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/lua/lazy/pkg/rockspec.lua b/lua/lazy/pkg/rockspec.lua index e8ece1b..7d7c4a4 100644 --- a/lua/lazy/pkg/rockspec.lua +++ b/lua/lazy/pkg/rockspec.lua @@ -25,6 +25,27 @@ M.rewrites = { M.python = { "python3", "python" } +---@class LuaRocks +M.luarocks = {} + +-- check which executable to call for luarocks, considering windows exceptions +-- @return string +function M.luarocks.execname() + local luarocks = "luarocks" + if Util.is_win then + local luarocks_win = "luarocks.exe" + if vim.fn.executable(luarocks_win) == 1 then + luarocks = luarocks_win + else + luarocks_win = "luarocks.bat" + if vim.fn.executable(luarocks_win) == 1 then + luarocks = luarocks_win + end + end + end + return luarocks +end + ---@class HereRocks M.hererocks = {} @@ -87,7 +108,8 @@ function M.check(opts) ) end else - ok = Health.have("luarocks", opts) + local luarocks = M.luarocks.execname() + ok = Health.have(luarocks, opts) Health.have( { "lua5.1", "lua", "lua-5.1" }, vim.tbl_extend("force", opts, { @@ -133,7 +155,7 @@ function M.build(task) end local env = {} - local luarocks = "luarocks" + local luarocks = M.luarocks.execname() if Config.hererocks() then -- hererocks is still building, so skip for now -- a new build will happen in the next round @@ -151,9 +173,6 @@ function M.build(task) env = { PATH = table.concat(path, sep), } - if Util.is_win then - luarocks = luarocks .. ".bat" - end end local pkg = task.plugin._.pkg