anomalyco / anomalyco/opencode
cross-spawn test: "captures stdout via .all when no stderr" asserts on shell-builtin echo, fails on Windows outside Git Bash
@nexxeln is already working on this.
Since Sep 9, 2026.
- Dominant language
- TypeScript
- Stars
- 209k
- Forks
- 27.5k
- PR merge metrics
- PR metrics pending
Description
Description
packages/core/test/effect/cross-spawn-spawner.test.ts has a case, "captures stdout via .all when no stderr", that passes or fails depending on what echo resolves to on PATH rather than on anything the spawner does.
The case spawns echo:
const handle = yield* ChildProcess.make("echo", ["hello from stdout"])
const all = yield* decodeByteStream(handle.all)
expect(all).toBe("hello from stdout")
On Linux echo is /bin/echo, a real binary, and it prints its argument without quotes. On Windows there is usually no echo.exe, so cross-spawn falls back to cmd.exe, which quotes the argument; cmd's builtin echo prints the rest of the line verbatim, quotes included. The stream then carries "hello from stdout" with the quote characters and the assertion fails.
The spawner is behaving correctly in both cases. The test is asserting on the behaviour of a shell builtin instead of on combined-output capture, which is what it is for.
Why this has probably not shown up in CI: .github/workflows/test.yml runs the Windows matrix entry with defaults.run.shell: bash, and in Git for Windows' bash a real echo.exe is on PATH — that is measured below on my own machine, I have not inspected the runner image itself. Under that shell the case takes the same path as Linux and passes. A Windows developer running bun test from PowerShell or cmd does not have that echo.exe and sees the failure.
The twin case one block below, "captures stderr via .all when no stdout", already uses the file's own js() helper to run node -e, so the fix is to make the stdout case match it.
OpenCode version
dev @ 9f8db119f (the file has been in this shape for a while; this is not a recent regression)
Steps to reproduce
- On Windows, from a shell where
echo.exeis not onPATH(PowerShell orcmd, not Git Bash), confirm withwhere.exe echo— it should report nothing. - From the repo root:
bun install cd packages/core && bun test test/effect/cross-spawn-spawner.test.ts- "captures stdout via .all when no stderr" fails with the received value quoted.
Isolated demonstration, same machine, same cross-spawn 7.0.6, only PATH differing:
const spawn = require("cross-spawn")
const child = spawn("echo", ["hello from stdout"], { stdio: ["ignore", "pipe", "pipe"] })
let out = ""
child.stdout.on("data", (b) => (out += b))
child.on("close", () => console.log(JSON.stringify(out)))
# PowerShell — echo not on PATH
"\"hello from stdout\"\r\n"
# Git Bash — echo resolves to C:\Program Files\Git\usr\bin\echo.EXE
"hello from stdout\n"
Operating System
Windows 11 Pro (10.0.22631)
Terminal
Windows Terminal (PowerShell 7)
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Assessment
This issue has not been assessed yet.