Skip to content
Latchkey

cargo install: Usage, Options & Common CI Errors

Install Rust command-line tools from crates.io or git.

cargo install compiles a binary crate and copies the executable into the Cargo bin directory (default ~/.cargo/bin). It is how CI gets tools like cargo-nextest, sccache, or cargo-audit.

What it does

Fetches a crate, builds it in release mode, and installs its binaries. Use --locked to build against the crate’s committed Cargo.lock for reproducibility.

Common usage

Terminal
cargo install ripgrep                 # latest from crates.io
cargo install cargo-nextest --locked  # reproducible build
cargo install cargo-audit --version 0.20.0
cargo install --git https://github.com/owner/tool --tag v1.0.0

Common CI error: binary not on PATH

After install the command is "not found" because ~/.cargo/bin is not on PATH in subsequent steps. On GitHub Actions add it with: echo "$HOME/.cargo/bin" >> "$GITHUB_PATH". If install fails to build, prefer --locked to avoid resolving newer, incompatible dependency versions.

Options

FlagEffect
--lockedUse the crate’s Cargo.lock
--version <v>Install a specific version
--git <url>Install from a git repo
--forceReinstall over an existing binary

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →