diff --git a/.changeset/fix-windows-arm64-error.md b/.changeset/fix-windows-arm64-error.md new file mode 100644 index 00000000000..e972d657a6a --- /dev/null +++ b/.changeset/fix-windows-arm64-error.md @@ -0,0 +1,5 @@ +--- +"@kilocode/cli": patch +--- + +Improve missing binary error message on Windows ARM64 to provide actionable workarounds (x64 emulation or WSL2). diff --git a/packages/opencode/bin/kilo b/packages/opencode/bin/kilo index f5a18633b86..56828f2ecd3 100755 --- a/packages/opencode/bin/kilo +++ b/packages/opencode/bin/kilo @@ -207,14 +207,25 @@ function findBinary(startDir) { } } +// kilocode_change start const resolved = envPath || (fs.existsSync(cached) ? cached : findBinary(scriptDir)) if (!resolved) { - console.error( - "It seems that your package manager failed to install the right version of the Kilo CLI for your platform. You can try manually installing " + - names.map((n) => `\"${n}\"`).join(" or ") + - " package", - ) + if (platform === "windows" && arch === "arm64") { + console.error( + "The Kilo CLI native binary for Windows ARM64 could not be found.\n" + + "If the native package is unavailable, you can try downloading the pre-built x64 binary from the GitHub Releases page to run under Windows 11 emulation.\n" + + "Alternatively, use WSL2 with the Linux ARM64 build." + ) + } else { + console.error( + "It seems that your package manager failed to install the right version of the Kilo CLI for your platform.\n" + + "You can try manually installing the " + + names.map((n) => `"${n}"`).join(" or ") + + " package, or download a pre-built binary from the GitHub Releases page." + ) + } process.exit(1) } +// kilocode_change end run(resolved, resolved === cached ? () => findBinary(scriptDir) : undefined) // kilocode_change - preserve cached binary fallback diff --git a/packages/opencode/script/postinstall.mjs b/packages/opencode/script/postinstall.mjs index 2b811968ce1..32bd59a850b 100644 --- a/packages/opencode/script/postinstall.mjs +++ b/packages/opencode/script/postinstall.mjs @@ -207,11 +207,13 @@ function main() { } } + // kilocode_change start throw new Error( `It seems your package manager failed to install the right Kilo CLI package. Try manually installing ${packageNames() .map((name) => JSON.stringify(name)) - .join(" or ")}.`, + .join(" or ")}. Or download the pre-built binary from the GitHub Releases page.`, ) +// kilocode_change end } try { diff --git a/packages/opencode/test/kilocode/bin-startup.test.ts b/packages/opencode/test/kilocode/bin-startup.test.ts index d4a170b8428..560dda99455 100644 --- a/packages/opencode/test/kilocode/bin-startup.test.ts +++ b/packages/opencode/test/kilocode/bin-startup.test.ts @@ -67,7 +67,9 @@ const trace = { probes: [], spawns: [], signals: [] } const signals = ["SIGINT", "SIGTERM", "SIGHUP"] const listeners = () => signals.map((signal) => process.listenerCount(signal)) os.platform = () => "win32" -os.arch = () => "x64" +// kilocode_change start +os.arch = () => input.arch ?? "x64" +// kilocode_change end os.hostname = () => input.host ?? "test-host" os.release = () => "10.0.26100" os.cpus = () => [{ model: "test CPU" }] @@ -242,4 +244,28 @@ describe("npm launcher startup", () => { expect(await Bun.file(join(root, "kilo", "bin", "windows-avx2.json")).exists()).toBe(true) expect((await item.run({ cache })).probes).toEqual([]) }) + +// kilocode_change start + test("prints helpful emulation message for missing binary on Windows ARM64", async () => { + await using item = await fixture() + await rm(item.optimized) + await rm(item.baseline) + const pkg = join(item.root, "node_modules", "@kilocode", "cli") + const wrapper = join(pkg, "bin", "kilo") + const preload = join(item.root, "preload.cjs") + + // Run the script directly to capture stderr, since findBinary will fail and call process.exit(1) + const proc = Bun.spawnSync([node, "--require", preload, wrapper], { + cwd: item.root, + env: { + KILO_STARTUP_TEST: JSON.stringify({ arch: "arm64" }), + KILO_STARTUP_LOG: item.root + "/trace.json", + }, + }) + const stderr = proc.stderr.toString() + expect(proc.exitCode).toBe(1) + expect(stderr).toContain("The Kilo CLI native binary for Windows ARM64 could not be found.") + expect(stderr).toContain("GitHub Releases page to run under Windows 11 emulation") + }) +// kilocode_change end })