fix(build): stamp .version files from a script, not Bun-hostile subshell redirects#1578
Open
aifllow wants to merge 1 commit into
Open
fix(build): stamp .version files from a script, not Bun-hostile subshell redirects#1578aifllow wants to merge 1 commit into
aifllow wants to merge 1 commit into
Conversation
…ell redirects Bun's shell (which runs npm scripts on Windows, where there is no /bin/sh) cannot parse `( cmd ) > file` — it errors "Subshells with redirections are currently not supported" on every Bun version (oven-sh/bun#11124, open). The build script's three `( git rev-parse HEAD 2>/dev/null || true ) > */dist/.version` stamps made `bun run build` abort at parse time on Windows, which blocked `/gstack-upgrade` for every Windows user. Move the stamping into scripts/gen-version-files.ts (Bun.write, no shell); output is byte-identical to the old form. Rewrite the second case of build-script-shell-compat.test.ts: the old assertion required a subshell redirect (built on the false premise that `( ) > file` is Bun-safe), the new one asserts no `>.version` shell redirect remains and that stamping is delegated to the script. macOS/Linux behaviour is unchanged. Fixes garrytan#1537
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
./setuprunsbun run build, and on Windows there is no/bin/sh, so Bun executes the npm script with its own shell. Bun's shell cannot parse( cmd ) > file— it aborts the whole script at parse time withSubshells with redirections are currently not supported(oven-sh/bun#11124, still open on every Bun version). Thebuildscript stamps three.versionfiles with( git rev-parse HEAD 2>/dev/null || true ) > …, so on Windows the binary compile never even starts. Net effect: every Windows user is blocked from/gstack-upgradepast v1.34.1.0.This moves the three stamps into
scripts/gen-version-files.ts(Bun.write, zero shell). Output is byte-identical to the old form: each file gets the newline-terminated HEAD SHA, or an empty file when git is unavailable / not a repo (matching the old2>/dev/null || true).Fixes #1537. Upstream limitation: oven-sh/bun#11124.
Why a script (vs. the other options in #1537)
Tested all three suggestions from the issue on Bun 1.3.10 / Windows:
git rev-parse HEAD > file 2>/dev/null || true(drop the subshell)error: expected a command or assignment but got: "Redirect"bash -c "…"setup.sh's build invocation for every platform — broader surface than the bugThe tail
(rm -f .*.bun-build || true)is intentionally left unchanged: Bun's shell only rejects subshells with redirections; a bare( cmd || true )parses and runs fine (verified). Changing it would be unrelated churn.Scope
scripts/gen-version-files.ts— new, 39 lines, no deps, file mode100644like the otherscripts/*.ts.package.json— the three( ) > .versionstamps becomebun run scripts/gen-version-files.ts. Nothing else in the build chain changes.test/build-script-shell-compat.test.ts— the second case asserted a subshell redirect must exist (toBeGreaterThan(0)), encoding the false premise that( ) > fileis Bun-safe. Rewritten to assert no>.versionshell redirect remains and that stamping is delegated to the script. The "no brace groups" case is unchanged..versionbytes, same build order.Test plan
bun run buildcompletes (exit 0) through Bun's shell — previously aborted at parse time on Windowsscripts/gen-version-files.tswrites all three.versionfiles withgit rev-parse HEAD, byte-identical to the old formbun test test/build-script-shell-compat.test.ts— 3 pass / 0 fail> file 2>/dev/null) and still accepts the unchanged bare-subshell tailPKG.scripts.build/scripts/gen-version-files.ts; the only failure in the curatedbun run test:windowsshard (skill-collision-sentinel) reproduces on a clean checkout and is unrelated to this changebun run buildparity — not verified here (no access); logic is platform-agnosticBun.write, output is byte-identical