opencode icon indicating copy to clipboard operation
opencode copied to clipboard

running opencode fails in alpine / musl based distros

Open markuest opened this issue 6 months ago • 6 comments

i am trying to get opencode working in my alpine WSL but running into the following issues

install using bun

Image

install using release

Image

workaround: running from source

Image

so it can run, just not with the official binaries

markuest avatar Jul 03 '25 14:07 markuest

Might be a alpine specific issue. I used the official oven/bun:alpine docker image, ran bun install -g opencode-ai. Tried running opencode and got an error sh: ./opencode: not found 🤷

JayJamieson avatar Jul 04 '25 10:07 JayJamieson

Image i can confirm. this keeps me from using opencode in alpine-based devcontainers

markuest avatar Jul 04 '25 10:07 markuest

FYI if you clone the repo you can run bun dev to run it just fine. You can also build your own binary and install it manually.

r1bilski avatar Oct 14 '25 14:10 r1bilski

The binary appears to be dynamically linked with glibc (/lib/ld-linux-aarch64.so.1):

file /usr/local/bin/opencode
/usr/local/bin/opencode: ELF 64-bit LSB executable, ARM aarch64, version 1 (SYSV), dynamically linked, interpreter /lib/ld-linux-aarch64.so.1, for GNU/Linux 3.7.0, BuildID[sha1]=76b7a6753f7bcf3ef62be90711f555de5656a276, not stripped

Stock alpine doesn't seem to know what to do with glibc-linked binaries since it uses musl instead.

One potential workaround (that seems to work in my case, at least) is to use this alpine-based image that includes glibc support: https://hub.docker.com/r/frolvlad/alpine-glibc/

I haven't tested it out thoroughly, but I was able to create a container with it and install a working opencode binary using just curl -fsSL https://opencode.ai/install | bash

banksean avatar Oct 18 '25 02:10 banksean

~~this has been fixed since v1.0~~ edit: this has not been fixed

markuest avatar Nov 03 '25 09:11 markuest

in my previous comment i tested with my own build instead of the official release. the issue still exists in v1.0.20

markuest avatar Nov 04 '25 11:11 markuest

https://github.com/sst/opencode/releases/tag/v1.0.56 includes a musl build now and it works on alpine for me

kalvenschraut avatar Nov 15 '25 07:11 kalvenschraut

thank you. tested it with 1.0.68 and i can confirm it works now.

markuest avatar Nov 17 '25 13:11 markuest