running opencode fails in alpine / musl based distros
i am trying to get opencode working in my alpine WSL but running into the following issues
install using bun
install using release
workaround: running from source
so it can run, just not with the official binaries
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 🤷
i can confirm. this keeps me from using opencode in alpine-based devcontainers
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.
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
~~this has been fixed since v1.0~~ edit: this has not been fixed
in my previous comment i tested with my own build instead of the official release. the issue still exists in v1.0.20
https://github.com/sst/opencode/releases/tag/v1.0.56 includes a musl build now and it works on alpine for me
thank you. tested it with 1.0.68 and i can confirm it works now.