zgcwkj runs magpie-cli-windows-amd64.exe as a Windows service (nssm) and every plugin install failed with "bun add …: exit status 0xc0000139: (and from the community repo's dist branch: bun add ./dist/….tgz: exit status 0xc0000139: )". Why: 0xc0000139 is STATUS_ENTRYPOINT_NOT_FOUND, the loader refusing the exe before it runs. Reading the PE imports (debug/pe) of Bun's windows-x64(-baseline) zips: 1.3.14 and later, so magpie's floor 1.4.2 and the latest 1.4.4, import kernel32's CreatePseudoConsole, ClosePseudoConsole and ResizePseudoConsole, which Windows has from 10 1809 (build 17763) / Server 2019 on. 1.3.13 doesn't. Bun's docs say "Windows 10 version 1809 or later" (bun.com/docs/installation). So Windows Server 2016 and Windows 10 1507 to 1803 (LTSB 2015/2016) can't run any Bun magpie uses. 1.4.2's pinned SHA-256 matches the asset. What changes: - wontLoad (internal/plugin/bun.go) reads an exit of 0xc0000139 as "this Windows" and 0xc000001d or SIGILL as "this processor" (Bun's x64 build targets SSE4.2), as a *BunUnstartableError whose message says which, the versions Bun needs, and MAGPIE_BUN. - bun add, bun update, cantStart and whyDied (the host's start) wrap it. - An install no longer tries the dist branch after it: that bun add can't start either, and its error read as the dist branch's. - The GUI's fail() answers it with code bun_unstartable, bunWhy and said, an i18n.js key (bunSaid in api.go), which api() in app.js puts through t(): en, zh, zh-TW, ja, de, in the window and in magpie web. The sentences live in Go so app.js grows one line: with both in app.js, TestCoreScriptBudget was 128 bytes over app.js's budget and 487 over the core's, and no budget is raised here. TestBunSaidIsTranslated fails when a language lacks one. The CLI prints the English message. - No fallback to an older Bun: 1.3.13 is below BunVersion and Bun doesn't support that Windows, and the -baseline assets are now the same binary. - docs/subsystems/provider-plugins.md says all this. Run: - New tests: TestWontLoadSaysWindowsOrCPU (injected NTSTATUS exits, a real kill -ILL), TestInstallOnUnstartableBunSaysWhyAndSkipsDist (0 dist requests), TestHostOnUnstartableBunSaysWhy, TestFailSaysBun Unstartable, TestBunSaidIsTranslated, plugin-bun-unstartable.test.cjs (chromium and webkit, every language, window and web). - Real Windows (10.0.26200 box, a sandbox dir of its own): a windows/amd64 nogui magpie-cli.exe with a fake magpie-bun.exe that exits 0xc0000139, `plugin add @magpie-community/opencode-raccoon-auth` printed the new message, and no dist folder was made. - gofmt -l; go vet darwin, linux -tags nogui, windows; builds of all three. - Full suite (go test -tags nogui -timeout 45m ./..., through suite-lock, ata6399dd49plus this change with both sentences in app.js): every package ok except internal/gui's TestCoreScriptBudget (128 bytes over app.js's budget, 487 over the core's). After the sentences moved to bunSaid: internal/gui and internal/plugin ok, budget included (core 1,528,331 of 1,528,525 before scoping the line to the code, ~20 bytes more after). - GUI (chromium and webkit, node --test): i18n-keys, every plugin-* file and signin-paste-plugin, 660 of 660 before the move to bunSaid; after it 656 of 660 at load ~140: plugin-card-update webkit (#3079) and plugin-quota-error chromium ja, whose Chromium launch hit Playwright's 180s timeout before the test ran. Both files alone: 16 of 16, 14 of 16 (which one not kept), 16 of 16, 16 of 16. - Rebased onff6090354: TestCoreScriptBudget, the new Go tests, plugin-bun-unstartable and i18n-keys again ok; gofmt; windows and linux vet of internal/plugin and internal/gui. Broken by hand (each restored): - wontLoad always nil: the three plugin tests fail, the install one with the reporter's exact "(and from the community repo's dist branch: …)" shape. - the dist skip removed: 1 dist request. - the whyDied check removed: the host test fails. - fail()'s block removed: the gui Go test fails. - app.js's line turned off: the GUI test fails, 16 of 16 (chromium). - one language's key renamed: TestBunSaidIsTranslated fails (3 of 4). Not tried: a real Windows before 1809 (the box is Windows 11) and a real processor without SSE4.2; zgcwkj's Windows version is still unknown.
51 lines
1.7 KiB
Go
51 lines
1.7 KiB
Go
package gui
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"net/http/httptest"
|
|
"os"
|
|
"strings"
|
|
"testing"
|
|
|
|
"github.com/yetone/magpie/internal/plugin"
|
|
)
|
|
|
|
// A plugin install on a bun this Windows or processor can't run answers
|
|
// with a code and the reason, which the page says in the reader's
|
|
// language (zgcwkj on Discord), wrapped however deep the install put it.
|
|
func TestFailSaysBunUnstartable(t *testing.T) {
|
|
bun := `C:\magpie\cache\bun\1.4.2\magpie-bun.exe`
|
|
ue := &plugin.BunUnstartableError{Bun: bun, Why: "windows", Err: fmt.Errorf("exit status 0xc0000139")}
|
|
rw := httptest.NewRecorder()
|
|
fail(rw, fmt.Errorf("bun add @magpie-community/opencode-raccoon-auth@latest: %w", ue))
|
|
var out map[string]string
|
|
if err := json.Unmarshal(rw.Body.Bytes(), &out); err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
if rw.Code != 400 || out["code"] != "bun_unstartable" || out["bunWhy"] != "windows" || out["bun"] != bun || out["error"] == "" || out["said"] != bunSaid["windows"] {
|
|
t.Fatalf("fail answered %d %v", rw.Code, out)
|
|
}
|
|
rw = httptest.NewRecorder()
|
|
fail(rw, fmt.Errorf("bun add x: exit status 1"))
|
|
out = nil
|
|
if err := json.Unmarshal(rw.Body.Bytes(), &out); err != nil || out["code"] != "" || out["said"] != "" {
|
|
t.Fatalf("an ordinary failure answered %v (%v)", out, err)
|
|
}
|
|
}
|
|
|
|
// What the page says for it is a key i18n.js has in every language: a
|
|
// t() of a word it lacks shows the English.
|
|
func TestBunSaidIsTranslated(t *testing.T) {
|
|
words, err := os.ReadFile("assets/i18n.js")
|
|
if err != nil {
|
|
t.Fatal(err)
|
|
}
|
|
for why, said := range bunSaid {
|
|
key, _ := json.Marshal(said)
|
|
if n := strings.Count(string(words), string(key)+":"); n != 4 {
|
|
t.Errorf("%s: i18n.js has %q in %d languages, want zh, zh-TW, ja and de", why, said, n)
|
|
}
|
|
}
|
|
}
|