fix(copilot): hint to run copilot directly when exec fails#13393
Open
babakks wants to merge 1 commit into
Open
fix(copilot): hint to run copilot directly when exec fails#13393babakks wants to merge 1 commit into
babakks wants to merge 1 commit into
Conversation
When the copilot binary is found in PATH but exec fails (e.g., due to unusual characters like parentheses in the path on Windows), append a hint suggesting the user run `copilot` directly without `gh`. The hint is only shown when the binary was already present on the host, not when it was freshly downloaded and installed by `gh`. Closes #13106 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a user-facing hint when gh copilot locates an existing copilot executable but fails to execute it (notably on Windows paths containing special characters), guiding users to run copilot directly as a workaround.
Changes:
- Tracks whether the Copilot CLI was found before attempting download/install and appends a hint to the error message on exec failures.
- Introduces injectable function variables for finding/running the external binary to enable deterministic testing.
- Adds a unit test asserting the hint is included and the original exec error remains wrapped.
Show a summary per file
| File | Description |
|---|---|
| pkg/cmd/copilot/copilot.go | Adds PATH-vs-install detection and appends a workaround hint on exec failures; adds indirection hooks for testing. |
| pkg/cmd/copilot/copilot_test.go | Adds a unit test validating the exec-failure hint behavior via injected hooks. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 2/2 changed files
- Comments generated: 1
Comment on lines
+146
to
+147
| foundInPath := copilotPath != "" | ||
| if !foundInPath { |
Member
There was a problem hiding this comment.
I feel like this is a fair comment, but if we downloaded it and we're failing to execute it, instructing the user to try something like copilot doesn't really hurt anything.
BagToad
approved these changes
May 11, 2026
BagToad
reviewed
May 11, 2026
Comment on lines
+186
to
+189
| // The binary exists in PATH but exec failed, possibly due to | ||
| // unusual characters in the path (see https://github.com/cli/cli/issues/13106). | ||
| // Suggest running copilot directly as a workaround. | ||
| return fmt.Errorf("%w\nTry running `copilot` directly without `gh`.", err) |
Member
There was a problem hiding this comment.
Suggested change
| // The binary exists in PATH but exec failed, possibly due to | |
| // unusual characters in the path (see https://github.com/cli/cli/issues/13106). | |
| // Suggest running copilot directly as a workaround. | |
| return fmt.Errorf("%w\nTry running `copilot` directly without `gh`.", err) | |
| // We found a `copilot` binary but exec failed, possibly due to | |
| // unusual characters in the path (see https://github.com/cli/cli/issues/13106). | |
| // Suggest running copilot directly as a workaround. | |
| return fmt.Errorf("%w\nFailed to run '%s', try running `copilot` directly without `gh`.", err, copilotPath) |
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.
Summary
When
gh copilotfinds thecopilotbinary inPATHbut fails to execute it (e.g., due to unusual characters like parentheses in the file path on Windows), the error message now includes a hint:The hint is only shown when the binary was already present on the host, not when it was freshly downloaded and installed by
gh.Details
On Windows,
cmd.exeshims (e.g., those planted by VS Code or npm) can fail when the path contains special characters like(. Sincegh copilotinvokes the binary viaos/exec, these failures surface as opaque errors. This change adds a practical workaround hint so users can still use Copilot CLI directly.Related to #13106