Repository navigation
fix: sourced libs locate themselves under zsh (#3024) - #3027
Closed
scottgigante-hubflow wants to merge 1 commit into
Closed
scottgigante-hubflow wants to merge 1 commit into
scottgigante-hubflow wants to merge 1 commit into
Conversation
bin/gstack-codex-probe and bin/gstack-egress-lib.sh are sourced into the host's shell by skill bash blocks. Under zsh (the macOS default, and what Claude Code's Bash tool runs there) BASH_SOURCE is unset, so: - the probe resolved its model resolver as "/../scripts/resolve-codex-generation-model.ts" and every Codex outside pass reported CODEX_MODEL: invalid / MODEL_UNUSABLE; the probe cache and analytics lookups silently found no state root. - the egress lib fell back to the caller's cwd and looked for gstack-state-root.sh in whatever repo the user was working in. Fall back to zsh's functions_source (probe, resolved at call time) and %x prompt expansion (egress lib, resolved at source time), each behind an eval so bash never parses zsh-only syntax. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
|
Merging to
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 |
scottgigante-hubflow
marked this pull request as ready for review
October 4, 2026 19:20
Contributor
|
Thanks for this. The Oct 6 fix wave rewrote the fix on branch |
Contributor
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.
Fixes #3024.
Why (in your own words)
Skill bash blocks source
bin/gstack-codex-probeandbin/gstack-egress-lib.shinto whatever shell the host runs. On macOS that is zsh, including Claude Code's Bash tool. Both libraries located themselves withBASH_SOURCE, and zsh doesn't set it. Since v1.91.16.0 (#3014), the probe has resolved its model resolver as/../scripts/resolve-codex-generation-model.ts, so every Codex outside pass (/ship,/review,/codex,/autoplan,/plan-eng-review,/office-hours) reportsMODEL_UNUSABLEand skips the review, even when Codex is installed, logged in and the model works. Under zsh the egress lib falls back to the caller's current directory, so_gstack_egress_homelooks forgstack-state-root.shin the user's project instead of in gstack. This is the case @akshaykalia raised on #3024.This PR adds a zsh fallback in both places. Each one sits behind an
evalso bash never has to parse zsh-only syntax:_gstack_codex_bin_dirhelper, resolved when called:BASH_SOURCEunder bash,functions_sourceunder zsh. All four call sites use it (model resolver, probe cache state root, analytics state root). The file still does nothing when sourced except define functions.BASH_SOURCE, else zsh's${(%):-%x}. The cwd fallback stays as the last resort.Live evidence
Before (v1.91.18.0, macOS, zsh 5.9), run from a directory outside gstack:
After, in both shells, from
/tmp:Sourcing the egress lib under
set -eustill works in both shells, andbash -n/zsh -npass on the probe.New regression test
test/regression-issue3024-zsh-sourced-self-locate.test.ts. It runs each case under bash and under zsh (zsh is skipped where it isn't installed), from an unrelated cwd so the cwd fallback can't pass by accident:Related suites still pass:
bun test test/codex-hardening.test.ts test/codex-model-probe.test.ts test/egress-lib.test.ts test/egress-receipt-wiring.test.ts test/aside-driver.test.tsgives 123 pass, 0 fail.Scope
bin/gstack-codex-probe,bin/gstack-egress-lib.sh, one new regression test._gstack_codex_model_probe; Linux or Windows shells; zsh older than 5.9. This PR doesn't bump VERSION or add a CHANGELOG entry, since those are left to the maintainer's release wave.Note: open PR #3025 adds a fifth
${BASH_SOURCE[0]%/*}use inbin/gstack-codex-probe(around line 138). Whichever PR merges second should switch that one to$(_gstack_codex_bin_dir)too.Liveness proof (required for external contributors)
🤖 Generated with Claude Code