Skip to content

Commit f7408ca

Browse files
Claudelpcox
andauthored
fix(ci): detect and set CARGO_HOME explicitly for rust tests (#745)
* Initial plan * fix(ci): detect and set CARGO_HOME explicitly for rust tests 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 26a2925 commit f7408ca

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

.github/workflows/test-chroot.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,11 +183,22 @@ jobs:
183183
echo "Captured GOROOT: ${GOROOT_VALUE}"
184184
185185
# Rust/Cargo: CARGO_HOME is needed so entrypoint can add $CARGO_HOME/bin to PATH
186-
# The rust-toolchain action sets CARGO_HOME but sudo may not preserve it
186+
# The rust-toolchain action doesn't set CARGO_HOME, so detect it from cargo location
187187
if [ -n "$CARGO_HOME" ]; then
188-
echo "CARGO_HOME=${CARGO_HOME}" >> $GITHUB_ENV
189-
echo "Captured CARGO_HOME: ${CARGO_HOME}"
188+
CARGO_HOME_VALUE="$CARGO_HOME"
189+
else
190+
# Detect CARGO_HOME from cargo binary location (usually ~/.cargo)
191+
CARGO_BIN=$(which cargo 2>/dev/null || echo "")
192+
if [ -n "$CARGO_BIN" ]; then
193+
# cargo is at $CARGO_HOME/bin/cargo, so strip /bin/cargo
194+
CARGO_HOME_VALUE=$(dirname "$(dirname "$CARGO_BIN")")
195+
else
196+
# Fallback to default location
197+
CARGO_HOME_VALUE="$HOME/.cargo"
198+
fi
190199
fi
200+
echo "CARGO_HOME=${CARGO_HOME_VALUE}" >> $GITHUB_ENV
201+
echo "Captured CARGO_HOME: ${CARGO_HOME_VALUE}"
191202
192203
# Java: JAVA_HOME is needed so entrypoint can add $JAVA_HOME/bin to PATH
193204
# The setup-java action sets JAVA_HOME but sudo may not preserve it

0 commit comments

Comments
 (0)