fix(gh-cli): exit 0 when CLAUDE_ENV_FILE is unset#135
fix(gh-cli): exit 0 when CLAUDE_ENV_FILE is unset#135dmaynor wants to merge 1 commit intotrailofbits:mainfrom
Conversation
When CLAUDE_ENV_FILE is not set by the runtime, setup-shims.sh exits 1, causing a SessionStart hook error in Claude Code. This is a graceful degradation case (shims simply won't be installed), not a fatal error. The gh-not-found guard on line 10 already exits 0 for the same reason. This change makes the CLAUDE_ENV_FILE guard consistent. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
David Maynor seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account. You have signed the CLA already but the status is still pending? Let us recheck it. |
There was a problem hiding this comment.
Pull request overview
Adjusts the gh-cli SessionStart hook to treat an unset CLAUDE_ENV_FILE as a non-fatal condition, avoiding startup hook failures while preserving “no shims installed” behavior.
Changes:
- Change
setup-shims.shtoexit 0(instead ofexit 1) whenCLAUDE_ENV_FILEis unset to allow graceful degradation.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if [[ -z "${CLAUDE_ENV_FILE:-}" ]]; then | ||
| echo "gh-cli: CLAUDE_ENV_FILE not set; shims will not be installed" >&2 | ||
| exit 1 | ||
| exit 0 |
There was a problem hiding this comment.
Changing this guard to exit 0 will require updating the existing bats test that currently asserts a non-zero exit status when CLAUDE_ENV_FILE is unset (plugins/gh-cli/hooks/setup-shims.bats, test "exits with error when CLAUDE_ENV_FILE is not set"). As-is, CI will fail because the test expects status 1 but the script now returns 0.
| exit 0 | |
| exit 1 |
Summary
setup-shims.shexits 1 whenCLAUDE_ENV_FILEis not set, causing aSessionStart:startup hook errorin Claude Codeghnot-found guard on line 10 which already exits 0exit 1→exit 0on line 16 for consistencyTest plan
SessionStart:startup hook errorfrom gh-cliCLAUDE_ENV_FILEis set, shims install normally (no behavior change)🤖 Generated with Claude Code