Skip to content

improve(github-cli): retry gh extension install before falling back to git clone - #1732

Draft
Ryosuke Hiroe (rhiroe) wants to merge 3 commits into
devcontainers:mainfrom
rhiroe:github-cli/improve/gh-extension-install-retry
Draft

Ryosuke Hiroe (rhiroe) wants to merge 3 commits into
devcontainers:mainfrom
rhiroe:github-cli/improve/gh-extension-install-retry

Conversation

@rhiroe

@rhiroe Ryosuke Hiroe (rhiroe) commented Sep 9, 2026

Copy link
Copy Markdown
Contributor

gh extension install failures fell through silently to the git-clone fallback. Retry it up to 3 times with backoff before falling back, since failures are most often transient (network/API rate limiting) rather than the extension being fundamentally unusable, and log each failed attempt's exit code so provisioning logs show why the fallback was hit.

Extensions that require a build step (e.g. github/gh-stack) are not usable after a plain git clone. Improving the fallback itself (e.g. downloading a prebuilt release binary) would add significant logic and ongoing maintenance cost, so that path is not pursued here; instead, after cloning, check for the expected gh- executable and exit 1 if it's missing, so a build-requiring extension fails provisioning loudly instead of leaving a broken extension in place.

@rhiroe
Ryosuke Hiroe (rhiroe) requested a review from a team as a code owner September 9, 2026 03:39
@rhiroe
Ryosuke Hiroe (rhiroe) marked this pull request as draft September 9, 2026 03:43
…o git clone

gh extension install failures fell through silently to the git-clone
fallback. Retry it up to 3 times with backoff before falling back,
since failures are most often transient (network/API rate limiting)
rather than the extension being fundamentally unusable, and log each
failed attempt's exit code so provisioning logs show why the fallback
was hit.

Extensions that require a build step (e.g. github/gh-stack) are not
usable after a plain git clone. Improving the fallback itself (e.g.
downloading a prebuilt release binary) would add significant logic and
ongoing maintenance cost, so that path is not pursued here; instead,
after cloning, check for the expected gh-<name> executable and exit 1
if it's missing, so a build-requiring extension fails provisioning
loudly instead of leaving a broken extension in place.
@rhiroe
Ryosuke Hiroe (rhiroe) force-pushed the github-cli/improve/gh-extension-install-retry branch from 2680c54 to e12403b Compare September 9, 2026 04:02
@rhiroe
Ryosuke Hiroe (rhiroe) marked this pull request as ready for review September 9, 2026 04:03

@v-Kaniska244 Kaniska (v-Kaniska244) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hi Ryosuke Hiroe (@rhiroe)

Would you please investigate the test failure?

@rhiroe

Copy link
Copy Markdown
Contributor Author

Apparently, as of gh v2.101.0, GitHub Copilot is a built-in command (gh copilot) instead of an extension, so gh extension install github/gh-copilot fails.

bash's 'if' returns 0 when the condition is false and there is no
else, so 'install_status=$?' right after the if always read 0
instead of the actual gh failure code.
@rhiroe

Copy link
Copy Markdown
Contributor Author

I created a pull request: #1741

@rhiroe
Ryosuke Hiroe (rhiroe) marked this pull request as draft September 18, 2026 01:36
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.

2 participants