arc-dind: "Copy Copilot CLI to daemon-visible path" fails with "are the same file" since v1.2.2
Summary
With runner.topology: arc-dind, the agent job fails at the step "Copy Copilot CLI to daemon-visible path":
cp: '/home/runner/_work/_temp/gh-aw/bin/copilot' and '/home/runner/_work/_temp/gh-aw/bin/copilot' are the same file
Error: Process completed with exit code 1.
Every release from v1.2.2 to v1.4.0 has the bug. v1.2.1 installs to ~/.local/bin, so the copy works there.
Cause
The compiler and the installer script disagree on where a rootless install lands.
-
useRootlessCLIInstallationreturnstrueforarc-dind(pkg/workflow/runner_config.go), so the lock runsinstall_copilot_cli.sh <version> --rootless .... -
Since v1.2.2,
setup/sh/install_copilot_cli.shinstalls rootless into$(prepare_rootless_install_dir), which is$RUNNER_TEMP/gh-aw/bin, and adds that directory to$GITHUB_PATH. v1.2.1 and earlier used${HOME}/.local/bin. -
pkg/workflow/nodejs.gostill assumes the old location. Its comment says "With--rootless, the binary is at~/.local/bin/copilot". It emits:mkdir -p "${RUNNER_TEMP}/gh-aw/bin" COPILOT_SRC="$(command -v copilot)" cp "$COPILOT_SRC" "${RUNNER_TEMP}/gh-aw/bin/copilot" chmod +x "${RUNNER_TEMP}/gh-aw/bin/copilot"
command -v copilot now returns ${RUNNER_TEMP}/gh-aw/bin/copilot, which is also the destination. GNU cp refuses to copy a file onto itself and exits 1.
Reproduction
Minimal frontmatter:
---
on:
workflow_dispatch:
engine:
id: copilot
runner:
topology: arc-dind
---
Say hello.
Compile with any release from v1.2.2 on and run on an ARC DinD runner scale set. The lock contains these two steps, in this order:
- name: Install GitHub Copilot CLI
run: bash "${RUNNER_TEMP}/gh-aw/actions/install_copilot_cli.sh" <version> --rootless ...
- name: Copy Copilot CLI to daemon-visible path
run: |
mkdir -p "${RUNNER_TEMP}/gh-aw/bin"
COPILOT_SRC="$(command -v copilot)"
cp "$COPILOT_SRC" "${RUNNER_TEMP}/gh-aw/bin/copilot"
chmod +x "${RUNNER_TEMP}/gh-aw/bin/copilot"
The second step fails with the error above.
Expected behaviour
The copy step succeeds, or is skipped, when the CLI is already at ${RUNNER_TEMP}/gh-aw/bin/copilot.
Suggested fix
Skip the copy when source and destination are the same file, in pkg/workflow/nodejs.go:
mkdir -p "${RUNNER_TEMP}/gh-aw/bin"
COPILOT_SRC="$(command -v copilot)"
if [ "$(readlink -f "$COPILOT_SRC")" != "$(readlink -f "${RUNNER_TEMP}/gh-aw/bin/copilot")" ]; then
cp "$COPILOT_SRC" "${RUNNER_TEMP}/gh-aw/bin/copilot"
fi
chmod +x "${RUNNER_TEMP}/gh-aw/bin/copilot"
Or drop the step entirely, since the rootless installer now targets that directory, and fix the stale comment.
Workarounds
The only workaround is pinning gh-aw to v1.2.1, whose installer still uses ~/.local/bin.
Environment
- gh-aw v1.3.1 (
github/gh-aw-actions/setup@dfe97a19c8249d41e2adfc95f92db2b8facea58f). The failing run used this version. I read the code of v1.2.2 through v1.4.0 and it matches. - Engine
copilot, withengine.version: "1.0.83"andengine.checksums-sha256set. - Self-hosted ARC scale set in Docker-in-Docker mode,
runner.topology: arc-dind.
Oh that's a duplicate of https://github.com/github/gh-aw/issues/76973