v1.39.2.0 fix: bun run build crashes on Windows from subshell-with-redirection#1531
Open
scarson wants to merge 2 commits into
Open
v1.39.2.0 fix: bun run build crashes on Windows from subshell-with-redirection#1531scarson wants to merge 2 commits into
scarson wants to merge 2 commits into
Conversation
added 2 commits
May 15, 2026 15:34
`( git rev-parse HEAD 2>/dev/null || true ) > path/.version` is POSIX-valid
but rejected by Bun's bundled shell on Windows with:
error: Subshells with redirections are currently not supported.
The same pattern caused the v1.38.0.0 → v1.39.1.0 ping-pong between brace
groups and subshells. Both forms are Bun-Windows-hostile; the third option
(`cmd 2>/dev/null > file` with multiple redirections) is also rejected. The
underlying constraint is that no single-line inline form of "swallow stderr,
swallow exit code, and write stdout to a file" parses under Bun shell on
Windows.
Move the .version writes into `scripts/write-versions.sh`, matching the
existing precedent of `browse/scripts/build-node-server.sh`. The build
script now calls `bash scripts/write-versions.sh` for all three files, and
the bash script handles both git-available and git-missing cases (the setup
script's safety net still backfills missing .version files at install time).
Tests:
- `no bash brace groups` — kept from prior version.
- `no subshell-with-redirection patterns` — new; catches the v1.39.1.0
regression.
- `no command with both stderr-suppress and stdout-redirect on one line` —
new; catches the third Bun-shell-hostile form.
- `.version writes are delegated to a bash script (not inline)` — new;
replaces the prior `must be a subshell` assertion, which gated on the
wrong property.
Verified end-to-end on Windows 11 + Git Bash + bun 1.3.13: `bun run build`
completes, all three `.version` files contain the correct HEAD SHA.
Reported during gstack global install upgrade from v1.32.0.0 → v1.39.1.0.
…ted by Bun shell) VERSION bump + CHANGELOG entry for the build-script fix in the previous commit. Required by the upstream version-gate workflow.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes #1530.
bun run buildcrashes on Windows + Git Bash + bun 1.3.13 with:The current
package.jsonscripts.buildcontains three( git rev-parse HEAD 2>/dev/null || true ) > path/.versionpatterns. Bun's bundled shell on Windows rejects all single-line forms of "swallow stderr, swallow exit code, write stdout to a file" — brace groups, subshells-with-redirect, and dual-redirect commands all fail. The only safe option is to delegate to bash.The same root cause produced the v1.38.0.0 → v1.39.1.0 ping-pong between brace groups and subshells (CHANGELOG v1.39.1.0 notes the brace-group regression; this PR notes that the v1.39.1.0 fix swapped to a different Bun-shell-hostile pattern). See #1530 for the full RCA and the matrix of Bun shell limitations observed.
Changes
scripts/write-versions.sh(new) — bash script that writesgit rev-parse HEADto all three.versionfiles. Mirrors the precedent ofbrowse/scripts/build-node-server.sh. Handles git-missing case cleanly; setup's existing safety net backfills missing.versionfiles at install time, so an empty file is acceptable.package.jsonscripts.build— replace the three subshell-with-redirect patterns withbash scripts/write-versions.sh. Net result: one shorter command instead of three POSIX-spelled-but-Bun-shell-rejected ones.test/build-script-shell-compat.test.ts— strengthen coverage:no bash brace groupstest kept.no subshell-with-redirection patternstest — catches the v1.39.1.0 regression that this PR fixes.no command with both stderr-suppress and stdout-redirecttest — catches the third Bun-shell-hostile form so future inline rewrites can't sneak it in.must be a subshelltest replaced with.version writes are delegated to a bash script— gates on the right property (delegation), not the previously-incorrect property (subshell prefix).Why a regex test is still useful
The strengthened regex test catches all three currently-observed Bun-shell-hostile patterns and prevents reintroduction. It does not predict future Bun shell limitations. A complementary follow-up would be to execute
bun run build(or a parse-only probe) underwindows-free-tests.yml— flagged in #1530 as a recommendation but out of scope for this PR.Test plan
bun test test/build-script-shell-compat.test.ts→ 4 pass, 0 fail (Windows 11 + bun 1.3.13)bun run buildend-to-end on Windows → exit 0; all three.versionfiles contain the correct HEAD SHA./setupend-to-end on Windows → "gstack ready (claude)."windows-free-tests.ymlruns the new test (currently includestest/build-script-shell-compat.test.tsper its existing test-list)Out of scope
bun run builditself under Windows CI as a regression net (mentioned as a recommendation in bun run build crashes on Windows: "Subshells with redirections are currently not supported" #1530).🤖 Generated with Claude Code