fix(copilot): hint to run copilot directly when exec fails#13393
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>
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
| foundInPath := copilotPath != "" | ||
| if !foundInPath { |
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.
Co-authored-by: Kynan Ware <47394200+BagToad@users.noreply.github.com>
|
@copilot fix the failing test |
Head branch was pushed to by a user without write access
Fixed in the latest commit. The test was checking for |
Summary
When
gh copilotfinds thecopilotbinary but 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: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