diff --git a/docs/subsystems/provider-plugins.md b/docs/subsystems/provider-plugins.md index f28ac016c..0fe68b161 100644 --- a/docs/subsystems/provider-plugins.md +++ b/docs/subsystems/provider-plugins.md @@ -159,7 +159,7 @@ Keep the migration, host, and upstream behavior separate when investigating fail The host gets magpie's proxy only as `MAGPIE_*_PROXY` and applies it to each fetch itself (`proxyFor`), and to each HTTP/2 session a plugin opens (`http2.connect`, `tunnel`, #1035). A host on the user's own network goes around that proxy as it does for magpie's own requests (`onLAN` in `host.js`, a port of `internal/netproxy/lan.go`'s: a private, link-local, loopback or CGNAT address, a `.local` name, or a name every address of which is one of those, looked up for 400 ms at most and kept a minute; #1572). A provider's own proxy is still taken as it is. The two rules are kept the same: a change to one is made in the other. A program a plugin starts, such as the Grok plugin's `grok login`, gets it back as `HTTPS_PROXY`/`HTTP_PROXY` from the spawn wrapper in `host.js`, unless the plugin set one. A sign-in that works in the built-in and fails through the plugin may be a host difference like this one, not a plugin bug. -magpie downloads the Bun build for this machine (`bunTarget` in [`bun.go`](../../internal/plugin/bun.go)): the baseline build on x64 Linux and Windows, and on a musl Linux such as Alpine (`libc.Musl`, the check Claude Code's download uses too) the musl one, `bun-linux-x64-musl-baseline` or `bun-linux-aarch64-musl`. A glibc build names glibc's loader, which Alpine lacks, so it couldn't start there and exec said "no such file or directory" (#1877). A musl Linux keeps its Buns and their `state.json` under `bun/musl`, so a machine whose C library changed never runs the other one's build or takes its set-aside versions; everywhere else they stay in `bun`, where a Bun downloaded before is. A bun that is on disk but can't be started says it is a build for another C library and names `MAGPIE_BUN` (`cantStart`), and it isn't fallen back from or set aside: the version before is the same build. Bun's musl build needs libstdc++ and libgcc; on an Alpine without them, `bun add` and the host's start say which library is missing and `apk add libstdc++ libgcc` (`missingLibs`). `TestBunTargetForMusl`, `TestMuslBunKeptApartFromGlibc`, `TestCantStartSaysCLibrary`, `TestHostOnUnstartableBunSaysCLibrary`, `TestMissingLibsNamesThem` and `TestHostOnBunLackingLibsSaysWhich` in [`bunmusl_test.go`](../../internal/plugin/bunmusl_test.go) cover these. +magpie downloads the Bun build for this machine (`bunTarget` in [`bun.go`](../../internal/plugin/bun.go)): the baseline build on x64 Linux and Windows, the native `bun-windows-aarch64` on Windows on ARM (it was turned away as having no build until #2183), and on a musl Linux such as Alpine (`libc.Musl`, the check Claude Code's download uses too) the musl one, `bun-linux-x64-musl-baseline` or `bun-linux-aarch64-musl`. A glibc build names glibc's loader, which Alpine lacks, so it couldn't start there and exec said "no such file or directory" (#1877). A musl Linux keeps its Buns and their `state.json` under `bun/musl`, so a machine whose C library changed never runs the other one's build or takes its set-aside versions; everywhere else they stay in `bun`, where a Bun downloaded before is. A bun that is on disk but can't be started says it is a build for another C library and names `MAGPIE_BUN` (`cantStart`), and it isn't fallen back from or set aside: the version before is the same build. Bun's musl build needs libstdc++ and libgcc; on an Alpine without them, `bun add` and the host's start say which library is missing and `apk add libstdc++ libgcc` (`missingLibs`). `TestBunTargetForMusl`, `TestMuslBunKeptApartFromGlibc`, `TestCantStartSaysCLibrary`, `TestHostOnUnstartableBunSaysCLibrary`, `TestMissingLibsNamesThem` and `TestHostOnBunLackingLibsSaysWhich` in [`bunmusl_test.go`](../../internal/plugin/bunmusl_test.go) cover these. Bun takes only http:// and https:// proxies. A SOCKS5 one, such as a Mac's system SOCKS proxy, is given to every bun magpie starts as a loopback HTTP proxy in front of it (`netproxy.Bridge`): to the host through `hostEnv`, and to `bun add`, `bun update` and `bun remove` through `bunCommand` (`netproxy.EnvForBun`). Before, an install with only a SOCKS system proxy failed as `UnsupportedProxyProtocol` (#1409). An agent CLI that bun installed is updated through the bridge too (`updateEnv` in `internal/agent/cliupdate.go`). diff --git a/internal/plugin/bun.go b/internal/plugin/bun.go index 269ec1fcc..c22f909f5 100644 --- a/internal/plugin/bun.go +++ b/internal/plugin/bun.go @@ -46,6 +46,7 @@ var bunSums = map[string]string{ "bun-linux-aarch64-musl.zip": "71760b6c8ea30623b81a4907cb815d48e2ea266f2e73e751534a44a0607950df", "bun-linux-x64-musl-baseline.zip": "76e1db84e98f22f78de0a87e309bfbbf297732847f9720db36750646c85c8c18", "bun-windows-x64-baseline.zip": "78c221c2376f79731ccf4e4af0b3bb46d81fefa3296c5abee09ad8a1b21e68c6", + "bun-windows-aarch64.zip": "a7a16b876a305fd1029c66dbd27007b4f6112ae896532f675878731a21e50cfd", "bun-linux-aarch64-android.zip": "a1c7e2983f1bb65146beb256a4d72449f23042412bc2cf278aa6397ba27e0274", "bun-linux-x64-android-baseline.zip": "fe36d8d4795e0eadc22fb6696d44d168491c2e5b9b7cbb12b8c96b0c0c40a4f9", } @@ -71,7 +72,8 @@ var bunPlatform = func() (goos, goarch string, musl bool) { // bunTarget is the name of Bun's build for this machine: bun-darwin-aarch64 // and the like. x64 Linux and Windows get the baseline build, which runs -// on CPUs without AVX2 as well; a musl Linux gets the musl build. +// on CPUs without AVX2 as well; arm64 has no baseline build, on Windows +// either; a musl Linux gets the musl build. func bunTarget() (string, error) { return bunTargetFor(bunPlatform()) } @@ -99,9 +101,7 @@ func bunTargetFor(goos, goarch string, musl bool) (string, error) { } return t, nil case "windows": - if arch != "x64" { - return "", fmt.Errorf("Bun has no build for windows/%s", goarch) - } + // Windows on ARM has Bun's native bun-windows-aarch64 (#2183) default: return "", fmt.Errorf("Bun has no build for %s", goos) } diff --git a/internal/plugin/bunmusl_test.go b/internal/plugin/bunmusl_test.go index b7c4d503a..2de0d9a17 100644 --- a/internal/plugin/bunmusl_test.go +++ b/internal/plugin/bunmusl_test.go @@ -36,13 +36,14 @@ func TestBunTargetForMusl(t *testing.T) { {"linux", "arm64", false, "bun-linux-aarch64"}, {"darwin", "arm64", true, "bun-darwin-aarch64"}, {"windows", "amd64", true, "bun-windows-x64-baseline"}, + {"windows", "arm64", false, "bun-windows-aarch64"}, {"android", "arm64", true, "bun-linux-aarch64-android"}, } { got, err := bunTargetFor(c.goos, c.goarch, c.musl) if err != nil || got != c.want { t.Errorf("bunTargetFor(%s, %s, musl %v) = %q, %v; want %q", c.goos, c.goarch, c.musl, got, err, c.want) } - if c.goos == "linux" && bunChecksum(BunVersion, got) == "" { + if bunChecksum(BunVersion, got) == "" { t.Errorf("no checksum for %s", got) } } diff --git a/internal/plugin/bunupdate_test.go b/internal/plugin/bunupdate_test.go index d581c01bf..f47061903 100644 --- a/internal/plugin/bunupdate_test.go +++ b/internal/plugin/bunupdate_test.go @@ -99,6 +99,7 @@ func TestBunDefaultSums(t *testing.T) { "bun-linux-aarch64-musl", "bun-linux-x64-musl-baseline", "bun-windows-x64-baseline", + "bun-windows-aarch64", "bun-linux-aarch64-android", "bun-linux-x64-android-baseline", } { @@ -131,6 +132,7 @@ func TestBunTarget(t *testing.T) { "linux/arm64": "bun-linux-aarch64", "linux/amd64": "bun-linux-x64-baseline", "windows/amd64": "bun-windows-x64-baseline", + "windows/arm64": "bun-windows-aarch64", "android/arm64": "bun-linux-aarch64-android", "android/amd64": "bun-linux-x64-android-baseline", }[runtime.GOOS+"/"+runtime.GOARCH] @@ -146,6 +148,28 @@ func TestBunTarget(t *testing.T) { } } +// Windows on ARM downloads Bun's native bun-windows-aarch64 build, with +// the checksum magpie carries for it, and runs plugins on it: it was +// turned away as having no build (#2183, EdwinDigital). +func TestWindowsOnArmGetsNativeBun(t *testing.T) { + bunHome(t, BunVersion, time.Now()) + stubPlatform(t, "windows", "arm64", false) + if got, err := bunTarget(); err != nil || got != "bun-windows-aarch64" { + t.Fatalf("bunTarget = %q, %v; want bun-windows-aarch64", got, err) + } + if got := bunChecksum(BunVersion, "bun-windows-aarch64"); got != "a7a16b876a305fd1029c66dbd27007b4f6112ae896532f675878731a21e50cfd" { + t.Fatalf("bun-windows-aarch64 checksum = %q, not Bun %s's SHASUMS256.txt", got, BunVersion) + } + asked := bunReleases(t, []byte("windows arm64 build")) + exe, err := Bun(context.Background()) + if err != nil { + t.Fatal(err) + } + if b, _ := os.ReadFile(exe); string(b) != "windows arm64 build" || asked.Load() != 1 { + t.Fatalf("Bun = %s holding %q after %d downloads", exe, b, asked.Load()) + } +} + // A Bun out two days is taken: downloaded, its checksum checked, tried, // and run from then on; the one before it is kept to fall back on. func TestCheckBunTakesASettledRelease(t *testing.T) {