Skip to content

fix: detect musl vs glibc for Alpine Linux npm install#9574

Closed
0byte-coding wants to merge 1 commit into
anomalyco:devfrom
0byte-coding:fix/alpine-musl-detection
Closed

fix: detect musl vs glibc for Alpine Linux npm install#9574
0byte-coding wants to merge 1 commit into
anomalyco:devfrom
0byte-coding:fix/alpine-musl-detection

Conversation

@0byte-coding

Copy link
Copy Markdown

Summary

Fixes #9571

When installing opencode-ai via npm on Alpine Linux, the installation fails because the wrapper script and postinstall script don't detect musl vs glibc, causing them to look for the wrong binary package.

Changes

  • Add musl/glibc detection to packages/opencode/bin/opencode wrapper script
  • Add musl/glibc detection to packages/opencode/script/postinstall.mjs
  • Uses the same detection logic already present in packages/opencode/script/publish-registries.ts

Root Cause

Both scripts only detected platform and architecture but not the libc variant, producing package names like opencode-linux-x64 instead of opencode-linux-x64-musl for Alpine.

Testing

Before (Alpine):

podman run --rm alpine:latest sh -c "apk add nodejs npm && npm install -g opencode-ai && opencode --version"
# Error: spawnSync /usr/local/lib/node_modules/opencode-ai/node_modules/opencode-linux-x64/bin/opencode ENOENT

After (with fix):

  • Tested musl detection on Alpine: correctly detects -musl suffix
  • Tested on glibc system: correctly uses no suffix (default glibc)
  • Detection logic matches existing publish-registries.ts implementation

Related

The musl packages already exist on npm:

  • opencode-linux-x64-musl@1.1.26
  • opencode-linux-arm64-musl@1.1.26
  • opencode-linux-x64-baseline-musl@1.1.26

- Add musl/glibc detection to bin/opencode wrapper script
- Add musl/glibc detection to script/postinstall.mjs
- Fixes issue where npm install fails on Alpine Linux
- Uses same detection logic as publish-registries.ts

Fixes anomalyco#9571
@github-actions

Copy link
Copy Markdown
Contributor

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@rekram1-node

Copy link
Copy Markdown
Collaborator

/review

@github-actions

Copy link
Copy Markdown
Contributor

lgtm

@github-actions

Copy link
Copy Markdown
Contributor

Closing this pull request because it has had no updates for more than 60 days. If you plan to continue working on it, feel free to reopen or open a new PR.

@github-actions github-actions Bot closed this Mar 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: npm install fails on Alpine Linux (musl) - wrapper script doesn't detect musl variant

2 participants