fix(entrypoint): preserve setup-* PATH ordering in fallback hostedtoolcache scan#3143
Conversation
…uction In the else fallback branch (when AWF_HOST_PATH is not available), the hostedtoolcache scan was prepending all discovered bin dirs in filesystem traversal order. This clobbered the version priority established by setup-* actions (e.g. ruby/setup-ruby) via $GITHUB_PATH. Two changes to fix the ordering: 1. Read $GITHUB_PATH file entries and prepend them to the base PATH before the toolcache scan, matching the Actions runner behavior. 2. Change the toolcache scan from prepend to append (with dedup), so that $GITHUB_PATH entries and standard system paths retain priority over the filesystem-order toolcache discovery. Fixes: agent/entrypoint: hostedtoolcache find-prepend overwrites setup-* PATH ordering
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Pull request overview
Fixes PATH precedence in the chroot “fallback” startup script generated by containers/agent/entrypoint.sh when AWF_HOST_PATH is unset, so that tool versions selected by setup-* actions (via $GITHUB_PATH) reliably win over /opt/hostedtoolcache scan ordering.
Changes:
- Prepend
$GITHUB_PATHentries before scanning/opt/hostedtoolcache, matching Actions runner precedence. - Change hostedtoolcache PATH population to append (with dedup) rather than prepend, so discovered toolcache bins act as fallbacks.
Show a summary per file
| File | Description |
|---|---|
| containers/agent/entrypoint.sh | Adjusts chroot fallback PATH construction to honor $GITHUB_PATH priority and avoid hostedtoolcache overriding selected tool versions. |
Copilot's findings
Tip
Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Files reviewed: 1/1 changed files
- Comments generated: 2
| if [ -n "${GITHUB_PATH}" ] && [ -f "${GITHUB_PATH}" ]; then | ||
| _github_path_prefix="" | ||
| while IFS= read -r _gp_entry; do | ||
| [ -z "${_gp_entry}" ] && continue | ||
| _github_path_prefix="${_github_path_prefix}${_gp_entry}:" | ||
| done < "${GITHUB_PATH}" | ||
| [ -n "${_github_path_prefix}" ] && export PATH="${_github_path_prefix}${PATH}" |
| # Prepend entries from $GITHUB_PATH file (written by setup-* actions) so they | ||
| # take priority over the hostedtoolcache scan below. This replicates what the | ||
| # Actions runner normally does with GITHUB_PATH, preserving the version chosen | ||
| # by setup-ruby / setup-python / setup-node / etc. | ||
| if [ -n "${GITHUB_PATH}" ] && [ -f "${GITHUB_PATH}" ]; then |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@copilot address review feedback |
…ng unit test - Strip trailing CR from each GITHUB_PATH entry so Windows-style CRLF files don't corrupt PATH elements (mirrors src/host-env.ts behavior) - Add tests/chroot-path-ordering.test.sh: shell unit test that exercises the fallback PATH-building logic with a synthetic hostedtoolcache and validates setup-* priority, CRLF stripping, and dedup
Both review points addressed in the latest commit:
|
Smoke Test Results
Details:
Label not added (requires all tests to pass).
|
🔥 Smoke Test: Copilot BYOK (Offline) Mode
Running in BYOK offline mode ( Overall: PARTIAL PASS — BYOK inference ✅, file I/O ✅; MCP/HTTP checks inconclusive due to unexpanded template vars.
|
🤖 Smoke Test Results
Overall: FAIL — GitHub MCP returned 401 (credential issue in this environment). Pre-step outputs were not passed to the agent context.
|
Chroot Version Comparison Results
Overall: ❌ Not all tests passed — Python and Node.js versions differ between host and chroot environments.
|
🏗️ Build Test Suite Results
Overall: 8/8 ecosystems passed — ✅ PASS
|
|
Smoke Codex: FAIL Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "registry.npmjs.org"See Network Configuration for more information.
|
|
Gemini Smoke Test: FAIL (Connectivity ❌, PR Review ❌, Files ✅) Warning Firewall blocked 1 domainThe following domain was blocked by the firewall during workflow execution:
network:
allowed:
- defaults
- "localhost"See Network Configuration for more information.
|
Smoke Test Results
Overall: FAIL —
|
Bug Fix
What was the bug?
In the
elsefallback branch ofcontainers/agent/entrypoint.sh(active whenAWF_HOST_PATHis unset), the chroot startup script scanned/opt/hostedtoolcacheand prepended every discovered*/bindirectory in filesystem traversal order. With multiple versions of a tool installed (e.g. Ruby 3.1 and 3.3), the wrong version would win thePATHrace regardless of whatsetup-rubywrote to$GITHUB_PATH, causingbundle execto fail with a version mismatch on first use.How did you fix it?
Two changes to the fallback heredoc in
containers/agent/entrypoint.sh:Read
$GITHUB_PATHfirst. Before the toolcache scan, prepend entries from the$GITHUB_PATHfile in declaration order — matching the Actions runner's own behavior and givingsetup-*tools highest priority.Append toolcache dirs instead of prepend, with dedup. The toolcache scan now adds undiscovered bin dirs to the end of
$PATH, so they serve as fallbacks rather than overriding explicit version selections.The
if/AWF_HOST_PATHbranch (normal GitHub Actions path, wheremergeGitHubPathEntriesalready bakes in$GITHUB_PATH) is unchanged.