fix: probe libc before selecting bundled CLI binary (#296)#305
Draft
MukundaKatta wants to merge 1 commit into
Draft
fix: probe libc before selecting bundled CLI binary (#296)#305MukundaKatta wants to merge 1 commit into
MukundaKatta wants to merge 1 commit into
Conversation
Reference implementation for issue anthropics#296. The bundled sdk.mjs resolver on Linux currently tries the musl variant first and never verifies that the resolved path exists on disk. This breaks two real install layouts: - pnpm installs both optional packages, the resolver picks musl, and spawn fails on glibc hosts because the musl ld-linker is missing - npm correctly skips the musl optional dep on glibc, but the resolver still hands back a musl-shaped path that doesn't exist on disk The new module: - detects glibc vs musl via process.report.getReport(), then ldd --version, then a filesystem probe of known loader paths - orders candidates by detected libc (glibc-first when unknown) - verifies each candidate exists on disk before returning it, falling through otherwise This repo is issues-only; the fix lives under proposed-fixes/issue-296 as a self-contained TS module + vitest tests for Anthropic to drop into the closed-source sdk.mjs build. 21 tests cover detection, ordering, existence fallback, and the null-when-truly-missing case. Closes anthropics#296.
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.
Note on repo structure
This repository is issues-only: the published
@anthropic-ai/claude-agent-sdkpackage is built from a separate source tree. The fix here lives underproposed-fixes/issue-296/as a self-contained TS module plus vitest tests for the team to integrate into the closed-sourcesdk.mjsbuild. Happy to convert to a comment on #296 if that is the preferred channel.Summary
Reference implementation for #296. The bundled
sdk.mjsresolver on Linux tries the musl variant first and never verifies the resolved path exists on disk. This breaks two install scenarios:What it does
process.report.getReport().header.glibcVersionRuntime→ldd --versionparse → filesystem probe of loader paths → default to glibc when inconclusive.Test plan
npm test→ 21/21 vitest unit tests pass (detection heuristics, candidate ordering, existence fallback, null-when-truly-missing).tsc --noEmit→ clean.