[PR #9574] fix: detect musl vs glibc for Alpine Linux npm install #13153

Open
opened 2026-02-16 18:18:01 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/9574

State: open
Merged: No


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
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/9574 **State:** open **Merged:** No --- ## 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):** ```bash 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`
yindo added the pull-request label 2026-02-16 18:18:01 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#13153