install.sh: detect musl on non-Alpine distros

RO
2mo ago
+80-0

Problem

  • curl -fsSL https://bun.com/install | bash installs the glibc build on non-Alpine musl systems. The binary then fails to load: Error relocating /root/.bun/bin/bun: gnu_get_libc_version: symbol not found.
  • The cause is the musl check in src/runtime/cli/install.sh:89. It only tests for /etc/alpine-release. Gentoo musl, Void musl, and Chimera do not have that file, so the script picks bun-linux-aarch64.zip instead of bun-linux-aarch64-musl.zip.

Fix

  • Add two fallback probes after the Alpine check: a /lib/ld-musl-*.so.1 loader file, and ldd --version output that contains musl.
  • The loader file check cannot use the glibc loader path in reverse. gcompat provides a glibc-style loader on musl systems, as the reporter's ldd output shows.
  • The ldd probe uses a command substitution with || true, not a pipe into grep. musl's ldd --version exits non-zero, and the script runs under set -o pipefail.
  • Verified: test/cli/install-script.test.ts (new). It runs the real script with stub uname and ldd binaries and a local server in place of GitHub, and asserts which release asset the script requests. The musl test fails on the unpatched script.

Background

  • The install script maps uname -ms to a release target, then appends -musl for musl systems. The musl zip exists for both x64 and aarch64 (.buildkite/scripts/upload-release.sh).
  • The npm installer is not affected. packages/bun-release/src/platform.ts detects musl from process.report, which is distro independent. That is why npm install -g bun works on the reporter's system.

Fixes #40975


no test proof · iteration 0 · platform-specific test(s) that do not run on this machine, deferring to CI, which covers all platforms: test/cli/install-script.test.ts