Skip to content

Commit b0ec54e

Browse files
Claudelpcox
andauthored
fix: add CARGO_HOME/bin to GitHub Actions PATH for rust tests (#749)
* Initial plan * fix: add CARGO_HOME/bin to GitHub Actions PATH for rust tests The rust-toolchain action installs rustc/cargo at ~/.cargo/bin but doesn't add this directory to PATH. This causes "command not found" errors when running rustc/cargo in chroot mode tests. Fix by explicitly adding CARGO_HOME/bin to $GITHUB_PATH after detecting CARGO_HOME from the cargo binary location. This ensures both the host and the chroot environment can find Rust binaries. Also added a clarifying comment that CARGO_HOME must be exported so sudo -E can preserve it for the awf CLI. Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com> --------- Co-authored-by: anthropic-code-agent[bot] <242468646+Claude@users.noreply.github.com> Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
1 parent e3aae3f commit b0ec54e

1 file changed

Lines changed: 4 additions & 0 deletions

File tree

.github/workflows/test-chroot.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ jobs:
184184
185185
# Rust/Cargo: CARGO_HOME is needed so entrypoint can add $CARGO_HOME/bin to PATH
186186
# The rust-toolchain action doesn't set CARGO_HOME, so detect it from cargo location
187+
# We must export it so sudo -E can preserve it
187188
if [ -n "$CARGO_HOME" ]; then
188189
CARGO_HOME_VALUE="$CARGO_HOME"
189190
else
@@ -199,6 +200,9 @@ jobs:
199200
fi
200201
echo "CARGO_HOME=${CARGO_HOME_VALUE}" >> $GITHUB_ENV
201202
echo "Captured CARGO_HOME: ${CARGO_HOME_VALUE}"
203+
# Also add CARGO_HOME/bin to PATH so host's cargo/rustc are accessible
204+
echo "${CARGO_HOME_VALUE}/bin" >> $GITHUB_PATH
205+
echo "Added CARGO_HOME/bin to PATH"
202206
203207
# Java: JAVA_HOME is needed so entrypoint can add $JAVA_HOME/bin to PATH
204208
# The setup-java action sets JAVA_HOME but sudo may not preserve it

0 commit comments

Comments
 (0)