Skip to content

Comments

fix(ci): detect and set CARGO_HOME explicitly for rust tests#745

Merged
lpcox merged 2 commits intolpcox/port-one-shot-token-rustfrom
claude/fix-github-actions-workflow-again
Feb 12, 2026
Merged

fix(ci): detect and set CARGO_HOME explicitly for rust tests#745
lpcox merged 2 commits intolpcox/port-one-shot-token-rustfrom
claude/fix-github-actions-workflow-again

Conversation

@Claude
Copy link
Contributor

@Claude Claude AI commented Feb 12, 2026

The dtolnay/rust-toolchain action installs Rust binaries to ~/.cargo/bin but doesn't set the CARGO_HOME environment variable. Without CARGO_HOME, the container entrypoint can't add Cargo binaries to PATH, causing rustc --version and cargo --version tests to fail with exit code 127.

Changes

  • Detect CARGO_HOME from cargo binary location using which cargo | dirname | dirname
  • Fall back to ~/.cargo if cargo not found
  • Always set CARGO_HOME in $GITHUB_ENV regardless of whether it was pre-set

Before:

if [ -n "$CARGO_HOME" ]; then
  echo "CARGO_HOME=${CARGO_HOME}" >> $GITHUB_ENV
fi

After:

if [ -n "$CARGO_HOME" ]; then
  CARGO_HOME_VALUE="$CARGO_HOME"
else
  CARGO_BIN=$(which cargo 2>/dev/null || echo "")
  if [ -n "$CARGO_BIN" ]; then
    CARGO_HOME_VALUE=$(dirname "$(dirname "$CARGO_BIN")")
  else
    CARGO_HOME_VALUE="$HOME/.cargo"
  fi
fi
echo "CARGO_HOME=${CARGO_HOME_VALUE}" >> $GITHUB_ENV

This ensures the environment variable propagates through the chain: workflow → Node.js process (process.env.CARGO_HOME) → container env var (AWF_CARGO_HOME) → chroot PATH ($CARGO_HOME/bin).

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • https://api.github.com/graphql
    • Triggering command: /usr/bin/gh gh pr checks --json name,state,link --abbrev-ref HEAD /home/REDACTED/.local/bin/git (http block)
    • Triggering command: /usr/bin/gh gh pr view 745 --json isDraft,statusCheckRollup (http block)
  • https://api.github.com/repos/github/gh-aw-firewall/actions/runs
    • Triggering command: /usr/bin/gh gh run list --branch claude/fix-github-actions-workflow-again --limit 5 --json workflowName,status,conclusion,createdAt,headSha /home/REDACTED/.nvm/package.json /home/REDACTED/.nvm/rename_test.sh /home/REDACTED/.nvm/test -n 1000 (http block)

If you need me to access, download, or install something from one of these locations, you can either:

Co-authored-by: lpcox <15877973+lpcox@users.noreply.github.com>
@Claude Claude AI changed the title [WIP] Fix failing GitHub Actions workflow for Test Chroot Package Managers fix(ci): detect and set CARGO_HOME explicitly for rust tests Feb 12, 2026
@Claude Claude AI requested a review from lpcox February 12, 2026 07:44
@lpcox lpcox marked this pull request as ready for review February 12, 2026 07:44
Copilot AI review requested due to automatic review settings February 12, 2026 07:44
@lpcox lpcox merged commit f7408ca into lpcox/port-one-shot-token-rust Feb 12, 2026
@lpcox lpcox deleted the claude/fix-github-actions-workflow-again branch February 12, 2026 07:44
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes CARGO_HOME detection in the GitHub Actions test-chroot workflow. The dtolnay/rust-toolchain action installs Rust to ~/.cargo/bin but doesn't set the CARGO_HOME environment variable, causing tests to fail when the container entrypoint tries to add Cargo binaries to PATH.

Changes:

  • Detect CARGO_HOME from cargo binary location using which cargo | dirname | dirname
  • Fall back to ~/.cargo if cargo is not found
  • Always set CARGO_HOME in $GITHUB_ENV to ensure it propagates to the container
  • Update comment to correctly state that rust-toolchain action doesn't set CARGO_HOME

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants