Skip to content

Commit 9c537ae

Browse files
committed
fix: guard musl detection when ldd is unavailable
vim.system raises when the binary cannot be spawned, so probe for ldd with vim.fn.executable and wrap the call; default to glibc otherwise.
1 parent 2a65d8f commit 9c537ae

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

lua/lockfile/download.lua

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,19 @@ local function target_triple()
5757
return arch .. "-pc-windows-msvc"
5858
elseif sysname:find("linux", 1, true) then
5959
-- Distinguish musl from glibc; the binaries are not interchangeable.
60+
-- Guard the probe: `ldd` may be absent, and a missing binary makes
61+
-- vim.system raise rather than return.
6062
local libc = "gnu"
61-
local ldd = vim.system({ "ldd", "--version" }):wait()
62-
local out = ((ldd.stdout or "") .. (ldd.stderr or "")):lower()
63-
if out:find("musl", 1, true) then
64-
libc = "musl"
63+
if vim.fn.executable("ldd") == 1 then
64+
local ok, ldd = pcall(function()
65+
return vim.system({ "ldd", "--version" }):wait()
66+
end)
67+
if ok and ldd then
68+
local out = ((ldd.stdout or "") .. (ldd.stderr or "")):lower()
69+
if out:find("musl", 1, true) then
70+
libc = "musl"
71+
end
72+
end
6573
end
6674
return arch .. "-unknown-linux-" .. libc
6775
end

0 commit comments

Comments
 (0)