native: detect libc via process.report, not ldd#2
Merged
Jeff Lubetkin (jefflub-ashby) merged 1 commit intoJun 30, 2026
Merged
Conversation
isMusl() shelled out to `ldd --version` and treated any failure as musl. Minimal images (distroless/scratch) ship no `ldd`, so the call throws and a glibc host is misdetected as musl — selecting a platform package/prebuild that doesn't exist and failing at load with "Native addon not found for linux-x64-musl". Use Node's process.report.header.glibcVersionRuntime (set on glibc, absent on musl), with a /lib/ld-musl-* fallback and a glibc default. Verified: distroless debian13 now resolves linux-x64; node:alpine still resolves musl. Bump to 0.1.1. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
b5ce5b5
into
napi-jemalloc
38 of 39 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
isMusl()shells out toldd --versionand treats any failure as musl:Minimal runtime images (Google distroless,
scratch) ship nolddbinary, so theexecSyncthrows → the loader concludes musl on a glibc host → it buildsplatformKey = "linux-x64-musl", for which no prebuild/platform package exists, and fails at startup:This bit a real deploy onto
gcr.io/distroless/nodejs24-debian13(glibc,glibcVersionRuntime: 2.41) — the correctlinux-x64binary was present but never selected.Fix
Detect libc using Node's own
process.report.header.glibcVersionRuntime(set on glibc, absent on musl) — no subprocess, so it works in minimal images. Falls back to probing/lib/ld-musl-*on older runtimes withoutprocess.report, and defaults to glibc (the common case) when uncertain.Verification
gcr.io/distroless/nodejs24-debian13:nonroot(glibc):isMusl()→ false; loader selectslinux-x64and parses (version: 180004). ✅node:24-alpine(musl):isMusl()→ true. ✅Bumps the package to
0.1.1.🤖 Generated with Claude Code