Skip to content

fix(gh-cli): exit 0 when CLAUDE_ENV_FILE is unset#135

Open
dmaynor wants to merge 1 commit intotrailofbits:mainfrom
dmaynor:fix/gh-cli-setup-shims-exit-code
Open

fix(gh-cli): exit 0 when CLAUDE_ENV_FILE is unset#135
dmaynor wants to merge 1 commit intotrailofbits:mainfrom
dmaynor:fix/gh-cli-setup-shims-exit-code

Conversation

@dmaynor
Copy link
Copy Markdown

@dmaynor dmaynor commented Mar 26, 2026

Summary

  • setup-shims.sh exits 1 when CLAUDE_ENV_FILE is not set, causing a SessionStart:startup hook error in Claude Code
  • This is a graceful degradation case (shims won't install), not a fatal error — identical to the gh not-found guard on line 10 which already exits 0
  • Changes exit 1exit 0 on line 16 for consistency

Test plan

  • Start a Claude Code session — no more SessionStart:startup hook error from gh-cli
  • When CLAUDE_ENV_FILE is set, shims install normally (no behavior change)

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings March 26, 2026 23:25
Copy link
Copy Markdown

@claude claude bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


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.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.sh to exit 0 (instead of exit 1) when CLAUDE_ENV_FILE is 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
Copy link

Copilot AI Mar 26, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
exit 0
exit 1

Copilot uses AI. Check for mistakes.
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.

3 participants