Skip to content

fix(bun-version): the floor comparison fails open when sourced from zsh (#3195) - #3214

Closed
schienbiz wants to merge 1 commit into
garrytan:mainfrom
schienbiz:fix-bun-floor-zsh
Closed

schienbiz wants to merge 1 commit into
garrytan:mainfrom
schienbiz:fix-bun-floor-zsh

Conversation

@schienbiz

Copy link
Copy Markdown
Contributor

Fixes #3195.

What breaks

/gstack-upgrade Step 4 sources bin/gstack-bun-version.sh in the agent's tool shell to check the incoming release's Bun floor. On a default macOS Claude Code that shell is zsh. _gstack_bun_below split "MAJOR MINOR PATCH" with an unquoted set -- "$1" $_gb_core, and zsh does not word-split unquoted parameters, so each [ -ne ] got "1 3 3", errored (integer expression expected), and the function returned 1 ("not below").

As a result, gstack_bun_status reports every version as ok under zsh, including Bun below GSTACK_BUN_FLOOR, the version the file's comment says loads a project's .env:

             bash        zsh (before)   zsh (after)
1.0.0        too-old     ok             too-old
1.3.2        too-old     ok             too-old
1.3.14       untested    ok             untested
1.4.2        ok          ok             ok

The bin/ callers (gstack-upgrade, gstack-session-update, setup) have bash shebangs and were not affected. Only callers that source the file from the user's shell were.

Change

  • bin/gstack-bun-version.sh: _gstack_bun_below compares named fields (_gb_r1..3, _gb_v1..3) instead of the word-split positional parameters. Same comparison logic, and nothing depends on word splitting.
  • test/setup-bun-floor.test.ts: the existing comparison table moves into a shared constant and runs under bash and, when installed, zsh (test.skipIf(!HAS_ZSH)).

Verification (macOS, bun 1.3.14, zsh 5.9, bash 5.3.9)

  • bun test test/setup-bun-floor.test.ts test/bun-version-drift.test.ts: 15 pass, 0 fail.
  • Mutation check: the new test against the old library fails on exactly this bug ("1.3.2": expected "too-old", received "ok"); the bash case still passes.
  • bun run test (full free suite) exits 1 locally. I re-ran the failing files the runner named, on this branch and on unmodified 47d639ab: the same 49 tests fail on both (CSO compiled-binary/hardened-runtime launcher, PTY redraw timing, autoplan run concurrency, setup skill copies). Separately, 2 tests in session-update-hook-hold.test.ts fail on base as well (they expect a repo-relative hook path but get a macOS /private/var/... temp path). None of them touch this file. The runner's "real home changed" warning came from my Claude Code session writing ~/.claude/backups during the run, not from a test. CI's Linux free-tests is the authoritative signal here.

Not bumping VERSION/CHANGELOG; leaving that to release time.

Still open from #3195 (not in this PR): a malformed floor still returns 1 from _gstack_bun_below, which callers read as "not below". Making that fail closed changes gstack_bun_incoming_hold's contract, so it seemed better as its own change.

🤖 Generated with Claude Code

…sh (#3195)

_gstack_bun_below split "MAJOR MINOR PATCH" with an unquoted
`set -- "$1" $_gb_core`. /gstack-upgrade sources gstack-bun-version.sh in
the agent's tool shell, which is zsh on a default macOS Claude Code, and
zsh does not word-split unquoted parameters. Every `[ -ne ]` then errored
("integer expression expected: 1 3 3"), the function returned 1, and
gstack_bun_status reported every version as `ok`, including Bun below the
security floor (1.3.2), so the pre-advance hold never fired.

Compare named fields instead. bash results are unchanged; zsh now matches
them for the whole comparison table, which the test runs under both shells
when zsh is installed. Reverting the library change fails the new zsh case
("1.3.2": expected too-old, received ok).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@trunk-io

trunk-io Bot commented Oct 16, 2026

Copy link
Copy Markdown

Merging to main in this repository is managed by Trunk.

  • To merge this pull request, check the box to the left or comment /trunk merge below.

After your PR is submitted to the merge queue, this comment will be automatically updated with its status. If the PR fails, failure details will also be posted here

@capy-ai

capy-ai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Triage (fix wave 5, GSTA-37): thanks, the diagnosis is right. #3195 is already fixed independently in wave 1a (#3202, commit 6eb0ac3, shipping in #3209): it compares quoted fields and treats an unparseable version as "malformed" instead of "not below". Your zsh table matches its tests. Once #3209 merges, this PR is superseded and will be closed with credit.

@capy-ai

capy-ai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Thank you, @schienbiz! This bug was fixed in v1.91.106.0 (main 3e8b34d, wave PR #3209). The fix landed as part of #3195: _gstack_bun_below no longer relies on word splitting, so zsh now reports a too-old Bun as too old, and an unparseable bun --version holds with BUN_VERSION_UNREADABLE. This PR was reviewed against that fix, which covers the same failure, so I'm closing it as already fixed. We appreciate the clear diagnosis.

@capy-ai capy-ai Bot closed this Oct 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bun floor check fails open when gstack-bun-version.sh is sourced from zsh

1 participant