emptyteeth found it: bunTarget picked Bun's build from GOOS/GOARCH alone,
so Alpine got bun-linux-x64-baseline, a glibc build whose interpreter
(/lib64/ld-linux-x86-64.so.2) Alpine lacks. exec then said "fork/exec
…/bun/1.4.2/magpie-bun: no such file or directory", which reads as a
missing file, and no plugin could be added or run.
- bunTarget: a musl Linux gets bun-linux-x64-musl-baseline or
bun-linux-aarch64-musl. The musl check moves out of internal/claudecode
into internal/libc (libc.Musl, unchanged rule: Anthropic's installer's
/lib/libc.musl-*.so.1), which claudecode, the plugin host and the CLI
test that skipped on musl now share.
- bunSums: the two musl builds' checksums, checked against Bun v1.4.2's
own SHASUMS256.txt (downloaded from the GitHub release; they match the
issue's numbers).
- Cache: a musl Linux keeps its Buns and state.json under bun/musl, so a
machine whose C library changed never runs the other build, nor takes
its state, whose Bad may list versions only the glibc build failed
(CheckBun on Alpine set aside every newer Bun). glibc, macOS and Windows
stay in bun/<v>, so a Bun downloaded before is used as it is, with no
new download.
- A bun on disk that exec can't start with ENOENT says it is a build for
another C library and names MAGPIE_BUN (cantStart), for the host's start
and for bun add/bun update. The same for a $MAGPIE_BUN.
- Bun's musl build needs libstdc++ and libgcc, which a bare Alpine lacks:
the loader then prints "Error loading shared library libstdc++.so.6"
above ~40 "Error relocating" lines, and bun add cut it off. bun add,
bun update and a host that died starting now say which library is
missing and `apk add libstdc++ libgcc` (missingLibs, whyDied).
Decided: a Bun that can't be started at all is not counted as crashed.
The fallback goes to the version before, which is the same build for
this system and fails the same way, and setting the current one aside
would mark a good version bad for good. The libc check happens before the
download instead (the target), so Alpine never fetches the glibc build.
Run:
- docker alpine:3.20 (arm64, and amd64 under emulation), sandbox HOME in
the container, linux nogui builds. origin/main's binary reproduces the
report: "bun add …: fork/exec /sbx/.cache/magpie/bun/1.4.2/magpie-bun:
no such file or directory". This one on bare Alpine downloads
bun/musl/1.4.2 and says "this system lacks libstdc++.so.6 … apk add
libstdc++ libgcc"; after apk add, `magpie plugin add
@magpie-community/opencode-cursor-auth` adds it and `plugin list` starts
the host and lists cursor (arm64 and amd64), with the old glibc
bun/1.4.2 left beside it unused. With libstdc++ removed again, plugin
list says the library; MAGPIE_BUN pointed at the glibc build gives the
C library message.
- New tests (bunmusl_test.go, libc_test.go), each broken by hand and seen
red: no musl branch (TestBunTargetForMusl, TestMuslBunKeptApartFromGlibc),
no bun/musl root (TestMuslBunKeptApartFromGlibc), cantStart returning
the error as is (TestCantStartSaysCLibrary,
TestHostOnUnstartableBunSaysCLibrary, which fails with the reporter's
exact message), host.go without it, no musl sum (TestBunDefaultSums),
no hint in bun add (TestMissingLibsNamesThem) or in the host's start
(TestHostOnBunLackingLibsSaysWhich), muslAt always false (TestMuslAt).
-race -count=20 on them: green.
- gofmt -l; go vet ./... on darwin, GOOS=linux -tags nogui, GOOS=windows;
go build for darwin, linux nogui, windows; go test -tags nogui for
internal/plugin, libc, claudecode, cli in a sandbox HOME, and
go test -tags nogui ./... (all green). One earlier run of
internal/plugin with the other three packages went red, and its output
was lost to a tail; four reruns of it, alone and together, were green,
and the new tests were green under -race -count=20, so which test it
was isn't known.
Not tried: a glibc Linux end to end after the change (the unit test
covers that its Bun stays at bun/<v>); a musl Linux other than Alpine
(the detection is unchanged and looks for Alpine's libc.musl-*.so.1).
The old glibc bun/<v> on an Alpine machine stays on disk (~90 MB); it
isn't removed, as a volume shared with a glibc container could be using
it.