Skip to content

Commit d98aecd

Browse files
Mossakaclaude
andcommitted
fix(chroot): pass CARGO_HOME and JAVA_HOME for CI runners
Similar to the GOROOT fix, this adds support for passing CARGO_HOME and JAVA_HOME environment variables to the chroot environment. These are needed because: 1. Rust toolchain on GitHub Actions installs cargo/rustc to $CARGO_HOME/bin which needs to be added to PATH explicitly 2. Java setup actions set JAVA_HOME but $JAVA_HOME/bin may not be in PATH when running through sudo The fix: - docker-manager.ts now passes AWF_CARGO_HOME and AWF_JAVA_HOME - entrypoint.sh adds these directories to PATH in the generated script - JAVA_HOME is also exported so Java can find its runtime This fixes the "command not found" errors (exit code 127) for cargo, rustc, and java commands in chroot mode on GitHub Actions. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 647a54a commit d98aecd

2 files changed

Lines changed: 22 additions & 2 deletions

File tree

containers/agent/entrypoint.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,18 @@ if [ "${AWF_CHROOT_ENABLED}" = "true" ]; then
217217
# Use the host's actual PATH (passed via AWF_HOST_PATH)
218218
export PATH="${AWF_HOST_PATH}"
219219
AWFEOF
220+
# Add CARGO_HOME/bin to PATH if provided (for Rust/Cargo on GitHub Actions)
221+
if [ -n "${AWF_CARGO_HOME}" ]; then
222+
echo "[entrypoint] Adding CARGO_HOME/bin to PATH: ${AWF_CARGO_HOME}/bin"
223+
echo "export PATH=\"${AWF_CARGO_HOME}/bin:\$PATH\"" >> "/host${SCRIPT_FILE}"
224+
echo "export CARGO_HOME=\"${AWF_CARGO_HOME}\"" >> "/host${SCRIPT_FILE}"
225+
fi
226+
# Add JAVA_HOME/bin to PATH if provided (for Java on GitHub Actions)
227+
if [ -n "${AWF_JAVA_HOME}" ]; then
228+
echo "[entrypoint] Adding JAVA_HOME/bin to PATH: ${AWF_JAVA_HOME}/bin"
229+
echo "export PATH=\"${AWF_JAVA_HOME}/bin:\$PATH\"" >> "/host${SCRIPT_FILE}"
230+
echo "export JAVA_HOME=\"${AWF_JAVA_HOME}\"" >> "/host${SCRIPT_FILE}"
231+
fi
220232
# Add GOROOT if provided (required for Go on GitHub Actions with trimmed binaries)
221233
if [ -n "${AWF_GOROOT}" ]; then
222234
echo "[entrypoint] Using host GOROOT for chroot: ${AWF_GOROOT}"

src/docker-manager.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,8 @@ export function generateDockerCompose(
334334
PATH: '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin',
335335
};
336336

337-
// For chroot mode, pass the host's actual PATH and GOROOT so the entrypoint can use them
338-
// This ensures toolcache paths (Python, Node, Go) are correctly resolved
337+
// For chroot mode, pass the host's actual PATH and tool directories so the entrypoint can use them
338+
// This ensures toolcache paths (Python, Node, Go, Rust, Java) are correctly resolved
339339
if (config.enableChroot) {
340340
if (process.env.PATH) {
341341
environment.AWF_HOST_PATH = process.env.PATH;
@@ -345,6 +345,14 @@ export function generateDockerCompose(
345345
if (process.env.GOROOT) {
346346
environment.AWF_GOROOT = process.env.GOROOT;
347347
}
348+
// Rust: Pass CARGO_HOME so entrypoint can add $CARGO_HOME/bin to PATH
349+
if (process.env.CARGO_HOME) {
350+
environment.AWF_CARGO_HOME = process.env.CARGO_HOME;
351+
}
352+
// Java: Pass JAVA_HOME so entrypoint can add $JAVA_HOME/bin to PATH and set JAVA_HOME
353+
if (process.env.JAVA_HOME) {
354+
environment.AWF_JAVA_HOME = process.env.JAVA_HOME;
355+
}
348356
}
349357

350358
// If --env-all is specified, pass through all host environment variables (except excluded ones)

0 commit comments

Comments
 (0)