Rust "rustup: command not found" in CI
The shell could not find rustup (or cargo) on PATH. Either Rust was never installed on the runner, or it is installed but ~/.cargo/bin was never added to PATH for this step.
What this error means
A step calling rustup or cargo fails instantly with "command not found", even on an image that supposedly has Rust. Common on bare images or after installing rustup in a previous step without exporting PATH.
./ci/build.sh: line 3: rustup: command not found
# or
cargo: command not foundCommon causes
Rust not installed on the runner
A minimal base image ships no Rust toolchain. rustup and cargo simply do not exist until you install them.
~/.cargo/bin not on PATH
rustup installs binaries to ~/.cargo/bin. If that directory isn’t on PATH - or a later step starts a fresh shell that never sourced ~/.cargo/env - the commands aren’t found.
How to fix it
Install rustup and add it to PATH
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
. "$HOME/.cargo/env"
rustc --versionPersist cargo bin to the job PATH
In GitHub Actions, write ~/.cargo/bin to $GITHUB_PATH so every later step finds cargo.
- run: |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- run: cargo build # now resolvesHow to prevent it
- Use a setup action (e.g.
dtolnay/rust-toolchain) instead of installing by hand. - Add
~/.cargo/binto$GITHUB_PATHso all steps see cargo. - Use the official
rustDocker image when you control the container.