Skip to content

Local embeddings fail on Alpine (musl): ERR_DLOPEN_FAILED — extend WASM fallback #364

Description

@kir-ka

Short description

onnxruntime-node native binding fails to load on Alpine (musl). Plugin should fall back to the WASM runtime it already uses for Electron instead of disabling local embeddings.

What happened?

On Alpine Linux (musl libc), embedding.provider: "local" fails because onnxruntime-node ships only glibc prebuilt binaries. The plugin already detects this exact failure via isNativeRuntimeMissingError() and — instead of falling back to the WASM runtime it already uses for Electron — simply disables local embeddings.

Environment:

  • OS: Alpine Linux (Docker), official image ghcr.io/anomalyco/opencode:latest
  • libc: musl (no __vsnprintf_chk)
  • Node.js: v24.18.1
  • opencode: 1.18.19
  • magic-context: v0.40.0
  • Note: the attached diagnostic report was captured with embedding.provider: "off" (the current workaround). The bug reproduces by setting embedding.provider: "local".

Error (doctor --harness opencode):

Embedding provider: local — onnxruntime-node native binding missing —
binding failed to load: ERR_DLOPEN_FAILED: Error relocating
.../onnxruntime-node/bin/napi-v6/linux/x64/libonnxruntime.so.1:
__vsnprintf_chk: symbol not found

Root cause:
__vsnprintf_chk is glibc-specific; Alpine's musl does not provide it, so dlopen() of the native libonnxruntime.so.1 fails. Upstream has no musl prebuilt: microsoft/onnxruntime#9483.

What the code already does:
embedding-local.ts already injects the WASM runtime via injectWasmOrtForElectron() (guarded by process.versions?.electron) and detects this exact failure via isNativeRuntimeMissingError(). So detection is present, but the response is "disable" rather than "use WASM".

Steps to reproduce

  1. docker run -it ghcr.io/anomalyco/opencode:latest
  2. Set embedding.provider: "local" in magic-context.jsonc
  3. Run: npx @cortexkit/magic-context@latest doctor --harness opencode
  4. Observe ERR_DLOPEN_FAILED: __vsnprintf_chk: symbol not found

Proposed change

When isNativeRuntimeMissingError() fires on a non-Electron runtime (musl/Alpine), fall back to the existing WASM injection instead of disabling local embeddings.

Related

Diagnostics

magic-context-issue-20260824-182207-full.md

Plugin version

v0.40.0

OpenCode version

1.18.19

Platform

Alpine Linux (Docker) — musl libc

Client

OpenCode web UI (browser, via serve on Docker)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions