Problem / motivation
opencode-mem cannot be loaded on Alpine Linux or any other musl-based distribution, so it cannot be used in Alpine containers.
Environment: OpenCode 2.0.32, opencode-mem 2.32.0, Alpine Linux 3.24 on aarch64.
The plugin installs, but OpenCode skips it at startup:
level=WARN message="failed to load plugin" target=opencode-mem@latest
cause="Error: Cannot find native binding. npm has a bug related to optional dependencies
(https://github.com/npm/cli/issues/4828). Please try `npm i` again after removing both
package-lock.json and node_modules directory."
The error text points at npm, but npm is not the cause. @tursodatabase/[email protected] publishes native bindings for only four platforms:
@tursodatabase/database-linux-x64-gnu
@tursodatabase/database-linux-arm64-gnu
@tursodatabase/database-darwin-arm64
@tursodatabase/database-win32-x64-msvc
On musl, its loader requires @tursodatabase/database-linux-arm64-musl (or -linux-x64-musl), and that package has never been published to npm.
Local embeddings have the same limitation: onnxruntime-node ships only glibc binaries for Linux. They are loaded lazily, though (src/services/embedding.ts, initializeModel), so remote embeddings (embeddingApiUrl + embeddingApiKey) never load onnxruntime. Once Turso ships musl bindings, musl users could run opencode-mem with remote embeddings.
Proposed solution
- Upstream: Turso needs to build and publish linux musl bindings. PR: bindings/javascript: build and publish linux musl binaries tursodatabase/turso#10107
- After a Turso release includes the musl packages, bump
@tursodatabase/database. Turso's main branch is already at 0.9.0-pre.1, which the current ^0.8.3 range does not include.
- In the README, list musl as supported with remote embeddings only, the same way Intel Mac is documented today.
- Optional: detect musl at startup and report a clear error instead of the misleading npm message, the way
onnxruntime-resolve.ts already does for Intel Mac. An Alpine job in platform-smoke.yml would keep musl from regressing.
Alternatives considered
- Installing
gcompat and dropping the glibc Turso binding in by hand. This is unsupported and fragile, and every auto-update (autoUpdate: true with @latest) wipes it out.
- Running OpenCode on a glibc distribution instead. This works, but it is not an option for Alpine-based images.
Additional context
- Turso build matrix:
bindings/javascript/packages/native/package.json (napi.targets) and .github/workflows/napi.yml in tursodatabase/turso.
- No existing opencode-mem issue mentions musl or Alpine.