Skip to content

Copilot CLI ENOENT on toolcache cache hit (ubuntu-latest, not arc-dind) — /usr/local/bin/copilot not staged #52464

Closed
Azure/azure-sdk-for-js
#39638

Description

@tcdhry

Summary

On GitHub-hosted ubuntu-latest runners (not arc-dind), the Execute GitHub Copilot CLI step intermittently fails with:

[copilot-harness] pre-flight: command not found: /usr/local/bin/copilot (F_OK check failed — binary does not exist at this path)
[copilot-harness] attempt 1: failed to start process '/usr/local/bin/copilot': spawn /usr/local/bin/copilot ENOENT
##[error]Process completed with exit code 1.

This happens whenever the Install GitHub Copilot CLI step gets a toolcache cache hit, and affects both the agent job and the detection job. In our observation it occurs on roughly 30-40% of runs.

This looks related to #44249, but the root cause and affected topology are different: #44249 is scoped to arc-dind self-hosted runners and was fixed by propagating RunnerConfig to the detection job. Our case reproduces on a plain GitHub-hosted ubuntu-latest runner, in the main agent job as well as detection, and the fix for #44249 does not appear to address it.

Environment

  • gh-aw compiler version: v0.85.4
  • awf version: v0.27.44
  • Runner: ubuntu-latest (GitHub-hosted, not self-hosted/arc-dind)
  • engine: copilot

Root cause (from reading actions/setup/sh/install_copilot_cli.sh)

On a toolcache cache hit (inside GitHub Actions), the script only adjusts PATH/GITHUB_PATH:

export PATH="${cached_copilot_dir}:$PATH"
echo "${cached_copilot_dir}" >> "${GITHUB_PATH}"

It does not copy or symlink the binary into /usr/local/bin. (Outside of GitHub Actions, where GITHUB_PATH isn't available, the script does install a wrapper script into /usr/local/bin as a fallback — but this fallback is skipped specifically when running inside GitHub Actions, since GITHUB_PATH is assumed sufficient.)

On a cache miss, the script instead extracts the tarball directly into the install dir:

maybe_sudo tar -xz -C "${INSTALL_DIR}" -f "${TEMP_DIR}/${TARBALL_NAME}"
maybe_sudo chmod +x "${INSTALL_DIR}/copilot"

So after a cache miss, /usr/local/bin/copilot exists; after a cache hit, it does not.

The problem: the awf-sandboxed execution harness (copilot_harness.cjs, invoked via awf --config ... -- /bin/bash -c '... /usr/local/bin/copilot ...') spawns Copilot via the hardcoded absolute path /usr/local/bin/copilot, not via PATH/command -v resolution. The chroot/container the harness runs in does not see the PATH mutation made by the install step in the host job (and the toolcache path itself is explicitly excluded from being mounted into the sandbox when it lives under /opt/*, which /opt/hostedtoolcache does). So whenever the install step took the "cache hit → PATH only" branch, the sandboxed harness cannot find the binary at all.

Evidence from our logs

Cache hit (fails):

Install GitHub Copilot CLI:
  Found candidate: /opt/hostedtoolcache/copilot-cli/1.0.78/x64/bin/copilot (version: 1.0.78, arch: x64)
  Cache age: 9 days (within TTL of 14 days)
  Using cached GitHub Copilot CLI from /opt/hostedtoolcache/copilot-cli/1.0.78/x64/bin/copilot
  Activating cached Copilot CLI from /opt/hostedtoolcache/copilot-cli/1.0.78/x64/bin/copilot...
    Prepended /opt/hostedtoolcache/copilot-cli/1.0.78/x64/bin to PATH
    Exporting /opt/hostedtoolcache/copilot-cli/1.0.78/x64/bin to GITHUB_PATH
...
Execute GitHub Copilot CLI:
  [copilot-harness] pre-flight: command not found: /usr/local/bin/copilot (F_OK check failed — binary does not exist at this path)
  [copilot-harness] attempt 1: failed to start process '/usr/local/bin/copilot': spawn /usr/local/bin/copilot ENOENT
  ##[error]Process completed with exit code 1.

Cache miss (succeeds, same workflow, different run):

Install GitHub Copilot CLI:
  Found candidate: .../copilot-cli/1.0.56/... Cache age: 75 days (exceeds TTL of 14 days)
  Skipping candidate (cache expired)
  No compatible toolcache entry found
  Downloading binary from https://github.com/github/copilot-cli/releases/download/v1.0.79/copilot-linux-x64.tar.gz...
  Installing binary to /usr/local/bin...
...
Execute GitHub Copilot CLI:
  [copilot-harness] pre-flight: command is accessible and executable: /usr/local/bin/copilot

Suggested fix

One of:

  1. Have the cache-hit branch always stage a copy/symlink of the cached binary into /usr/local/bin (i.e. apply the same wrapper-script fallback that's currently only used outside GitHub Actions), so the sandboxed harness's hardcoded path keeps working regardless of cache hit/miss.
  2. Have copilot_harness.cjs resolve the binary via command -v copilot / $PATH instead of a hardcoded /usr/local/bin/copilot, and ensure the resolved location (including toolcache paths) is actually reachable/mounted inside the awf sandbox.

Workaround

None found on the workflow-authoring side — the Install/Execute GitHub Copilot CLI steps are generated entirely by the compiler and can't be intercepted from the workflow's markdown frontmatter/body. Re-running the workflow is the only current mitigation, since each GitHub-hosted runner VM's toolcache state varies run to run.

Activity

  1. locked and limited conversation to collaborators on Aug 13, 2026
  2. unlocked this conversation on Aug 13, 2026
  3. added
    bug
    on Aug 13, 2026
  4. ckittel commented on Aug 13, 2026

    @ckittel

    See also: #52327 (which includes a workaround)

  5. locked and limited conversation to collaborators on Aug 13, 2026
  6. unlocked this conversation on Aug 13, 2026
  7. added a commit that references this issue on Aug 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugclicopilot

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions