Skip to content

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

Closed

Description

@0byte-coding

Description

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

Root Cause

Both packages/opencode/bin/opencode (line 47) and packages/opencode/script/postinstall.mjs (line 52) only detect platform and architecture but not the libc variant:

// bin/opencode line 47
const base = "opencode-" + platform + "-" + arch
// This produces: opencode-linux-x64

// postinstall.mjs line 52  
const packageName = `opencode-${platform}-${arch}`
// This produces: opencode-linux-x64

However, Alpine Linux (musl) requires the -musl suffix:

  • ✅ Available: opencode-linux-x64-musl, opencode-linux-arm64-musl
  • ❌ Looking for: opencode-linux-x64, opencode-linux-arm64

Reproduction

podman run --rm alpine:latest sh -c "apk add nodejs npm && npm install -g opencode-ai && opencode --version"

Actual output:

spawnSync /usr/local/lib/node_modules/opencode-ai/node_modules/opencode-linux-x64/bin/opencode ENOENT

Expected: Successfully installs and runs

Solution

The scripts need to detect musl vs glibc, similar to how packages/opencode/script/publish-registries.ts does it (lines 83-90):

if ldd --version 2>&1 | grep -qi musl; then
  libc="-musl"
fi
if [ -z "$libc" ] && ls /lib/ld-musl-* >/dev/null 2>&1; then
  libc="-musl"
fi

Files to Fix

  1. packages/opencode/bin/opencode - Add musl detection to line 47
  2. packages/opencode/script/postinstall.mjs - Add musl detection to line 52

Related

The musl packages already exist on npm:

Activity

  1. github-actions commented on Jan 20, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Both issues stem from the same problem: the wrapper script and postinstall script don't properly detect musl vs glibc libc variants. This affects Alpine Linux (missing musl detection) and WSL2 (incorrect musl selection on glibc systems).

    Feel free to ignore if none of these address your specific case.

  2. added a commit that references this issue on Jan 20, 2026
    b8038dc
  3. added a commit that references this issue on Jan 20, 2026
    9f4aafc
  4. github-actions commented on Mar 26, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions