Skip to content

Fix Copilot CLI toolcache hit not creating /usr/local/bin/copilot - #53490

Open
pelikhan with Copilot wants to merge 7 commits into
mainfrom
copilot/fix-copilot-cli-toolcache-issue-again
Open

Fix Copilot CLI toolcache hit not creating /usr/local/bin/copilot#53490
pelikhan with Copilot wants to merge 7 commits into
mainfrom
copilot/fix-copilot-cli-toolcache-issue-again

Conversation

Copilot AI commented Aug 17, 2026

Copy link
Copy Markdown
Contributor

On a runner toolcache hit, install_copilot_cli.sh activated the cached CLI by appending its directory to GITHUB_PATH and returned early, never creating ${INSTALL_DIR}/copilot. The agent is spawned with the literal absolute path /usr/local/bin/copilot, so spawn() failed with ENOENT and the run died before producing output ("Engine Failure: the copilot engine terminated before producing output"). Because it depends on what the runner happens to have cached, the same unchanged workflow succeeded or failed non-deterministically.

Changes

  • actions/setup/sh/install_copilot_cli.sh
    • activate_cached_copilot_bin now exports the cached dir to GITHUB_PATH and falls through to install the exec wrapper at ${INSTALL_DIR}/copilot, so the canonical path exists regardless of how the CLI was provisioned. The wrapper-install branch was previously dead code under Actions, where GITHUB_PATH is always set.
    • Skips wrapper creation when the cached binary already is ${INSTALL_DIR}/copilot, avoiding a self-exec loop.
    • Cached-install verification now fails fast if ${INSTALL_DIR}/copilot is missing or non-executable, so the failure surfaces in the setup step rather than as an opaque agent crash.
    • Added COPILOT_INSTALL_DIR override (consistent with the existing COPILOT_COMPAT_URL / COPILOT_COMPAT_BUNDLED_PATH test hooks) so tests can exercise the real install path without writing to /usr/local/bin.
  if [ -n "${GITHUB_PATH:-}" ]; then
    echo "$cached_copilot_dir" >> "${GITHUB_PATH}"
  fi
  # ...falls through: wrapper is installed at ${INSTALL_DIR}/copilot
  • pkg/cli/install_copilot_cli_test.go — toolcache tests now assert the canonical path is materialized:

    • explicit-version hit: wrapper exists, references the cached binary, and executes (--version);
    • dev-mode compat resolution (GH_AW_COMPILED_VERSION=dev): wrapper points at the best cached candidate;
    • rootless test updated for the new log messages.
  • Changeset added.

The alternatives noted in the issue — emitting the resolved path into the lock file, or a PATH fallback in copilot_harness.cjs — are larger and left out; the wrapper matches the script's own stated preference.


Run: https://github.com/github/gh-aw/actions/runs/32075123011> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 7.25 AIC · ⌖ 7.79 AIC · ⊞ 8.8K ·

Comment /souschef to run again


Run: https://github.com/github/gh-aw/actions/runs/32082636829> Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14.1 AIC · ⌖ 7.81 AIC · ⊞ 8.8K ·

Comment /souschef to run again

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix Copilot CLI toolcache cache-hit issue causing engine termination Fix Copilot CLI toolcache hit not creating /usr/local/bin/copilot Aug 17, 2026
Copilot AI requested a review from pelikhan August 17, 2026 21:11
@pelikhan
pelikhan marked this pull request as ready for review August 17, 2026 21:36
Copilot AI balanced review requested due to automatic review settings August 17, 2026 21:36

Copilot AI 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.

Pull request overview

Fixes cached Copilot CLI activation by ensuring the canonical executable path exists.

Changes:

  • Installs a wrapper for toolcache hits and verifies the canonical path.
  • Adds a test-only install-directory override.
  • Expands regression tests and adds a patch changeset.
Show a summary per file
File Description
actions/setup/sh/install_copilot_cli.sh Materializes the canonical Copilot wrapper.
pkg/cli/install_copilot_cli_test.go Tests wrapper creation and execution.
.changeset/patch-fix-copilot-toolcache-wrapper.md Documents the patch.

Review details

💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1
  • Review effort level: Balanced

Comment on lines +506 to 508
if [ "$cached_copilot_bin" = "${INSTALL_DIR}/copilot" ]; then
echo " Cached binary already lives at ${INSTALL_DIR}/copilot — no wrapper needed"
return 0

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Addressed in 5f5d213. The new test sets COPILOT_INSTALL_DIR to the selected toolcache bin, verifies the cached file is not replaced by a wrapper, and executes it successfully.

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot PR sous-chef triage: branch refresh was requested. Please run the pr-finisher skill and report any remaining blockers on this PR.

Run: https://github.com/github/gh-aw/actions/runs/32075123011

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 7.25 AIC · ⌖ 7.79 AIC · ⊞ 8.8K ·
Comment /souschef to run again

Copilot AI and others added 2 commits August 17, 2026 22:25
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>
Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 17, 2026

Copy link
Copy Markdown
Contributor Author

@copilot PR sous-chef triage: branch refresh was requested. Please run the pr-finisher skill and report any remaining blockers on this PR.

Run: https://github.com/github/gh-aw/actions/runs/320751...

Ran pr-finisher and completed the branch refresh cleanup in 19dce2b. Local formatting, lint, focused installer tests, full tests, recompilation, and the final impacted-test gate pass. Remaining blockers: the existing unresolved Copilot review thread, maintainer review, and approval/re-trigger of CI checks currently marked action_required (those runs created zero jobs).

Copilot AI requested a review from gh-aw-bot August 17, 2026 22:54
@pelikhan

Copy link
Copy Markdown
Collaborator

@lpcox review

@gh-aw-bot

Copy link
Copy Markdown
Collaborator

@copilot Please review any remaining unresolved feedback on this PR, refresh the branch if needed, then run the pr-finisher skill and report back with the current blockers and validation results.

Run: https://github.com/github/gh-aw/actions/runs/32082636829

Generated by 👨‍🍳 PR Sous Chef · gpt54 · 14.1 AIC · ⌖ 7.81 AIC · ⊞ 8.8K ·
Comment /souschef to run again

Co-authored-by: gh-aw-bot <259018956+gh-aw-bot@users.noreply.github.com>

Copilot AI commented Aug 18, 2026

Copy link
Copy Markdown
Contributor Author

@copilot Please review any remaining unresolved feedback on this PR, refresh the branch if needed, then run the pr-finisher skill and report back with the current blockers and validation results.

...

Ran pr-finisher. Commit 00005cb adds the requested self-wrapper regression test; I replied to the Copilot thread, but it still requires UI resolution. The branch is current with main. Formatting, lint, focused installer tests, impacted unit tests, recompilation, secret scan, and CodeQL pass. Full make test is blocked by a refreshed-base regression in TestCopilotEngineInstallationWithCopilotSDKDriver (current main removed ripgrep installation but the test still expects 3 steps). Current CGO/CWI checks are approval-gated (action_required) with zero jobs, so maintainer CI approval/re-trigger and review remain.

@github-actions

Copy link
Copy Markdown
Contributor

PR Triage

Category: bug · Risk: medium · Score: 73/100

Breakdown: impact 35/50 · urgency 20/30 · quality 18/20

Recommended action: fast_track

Fixes a real breakage: when the Copilot CLI toolcache is hit, /usr/local/bin/copilot was not being (re)created, breaking install_copilot_cli.sh on cache-hit runs. Includes a changeset and a new unit test (+93/-5, 3 files). This is the highest-priority PR in this run — affects Copilot CLI availability wherever the tool cache is reused. Recommend expedited human review.

Generated by 🔧 PR Triage Agent · auto · 46.6 AIC · ⌖ 1.9 AIC · ⊞ 8.3K ·

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Copilot CLI toolcache cache-hit never creates /usr/local/bin/copilot → agent dies with spawn ENOENT ("engine terminated before producing output")

4 participants