Skip to content

Commit f8b9196

Browse files
authored
Merge branch 'voidzero-dev:main' into main
2 parents e0dcda8 + 2223726 commit f8b9196

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

packages/cli/install.sh

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -141,22 +141,40 @@ curl_with_error_handling() {
141141

142142
# Detect libc type on Linux (gnu or musl)
143143
detect_libc() {
144-
# Check for musl dynamic linker (most reliable method)
145-
if [ -e /lib/ld-musl-x86_64.so.1 ] || [ -e /lib/ld-musl-aarch64.so.1 ]; then
146-
echo "musl"
147-
return
144+
# Prefer positive glibc detection first.
145+
# This avoids false musl detection on systems where musl is installed
146+
# but the distro itself is glibc-based (common on WSL/Ubuntu).
147+
if command -v getconf &> /dev/null; then
148+
if getconf GNU_LIBC_VERSION > /dev/null 2>&1; then
149+
echo "gnu"
150+
return
151+
fi
148152
fi
149153

150-
# Check if ldd exists and is musl-based
154+
# Check ldd output for musl/glibc
151155
if command -v ldd &> /dev/null; then
152-
if ldd --version 2>&1 | grep -qi musl; then
156+
ldd_out="$(ldd --version 2>&1 || true)"
157+
if echo "$ldd_out" | grep -qi musl; then
153158
echo "musl"
154159
return
155160
fi
161+
if echo "$ldd_out" | grep -qi 'gnu libc'; then
162+
echo "gnu"
163+
return
164+
fi
165+
if echo "$ldd_out" | grep -qi 'glibc'; then
166+
echo "gnu"
167+
return
168+
fi
156169
fi
157170

158-
# Default to gnu (glibc)
159-
echo "gnu"
171+
# Final fallback: musl loader present usually indicates musl-based distro,
172+
# but only check this after glibc detection to avoid false positives.
173+
if [ -e /lib/ld-musl-x86_64.so.1 ] || [ -e /lib/ld-musl-aarch64.so.1 ]; then
174+
echo "musl"
175+
else
176+
echo "gnu"
177+
fi
160178
}
161179

162180
# Detect platform

0 commit comments

Comments
 (0)