LinuxCommandLibrary

cargo-update

Update installed Rust binary crates

TLDR

Update dependencies in Cargo.lock to the latest possible version

$ cargo update
copy

Display what would be updated, but don't actually write the lockfile
$ cargo update [[-n|--dry-run]]
copy

Update only the specified dependencies
$ cargo update --package [dependency1] --package [dependency2] --package [dependency3]
copy

Set a specific dependency to a specific version
$ cargo update --package [dependency] --precise [1.2.3]
copy

SYNOPSIS

cargo-update [OPTIONS] [--] [<PACKAGE>...]

PARAMETERS

-a, --all
    Update all dependencies, even those without new versions available

--check
    Exit 0 if up-to-date, 1 if updates available (useful in CI)

--dry-run
    Simulate updates without modifying Cargo.lock

-p <SPEC>, --package <SPEC>
    Update only the specified package (e.g., rand@0.8.5)

--precise <VERSION>
    Update to an exact version string

--manifest-path <PATH>
    Path to Cargo.toml

--workspace
    Update dependencies of workspace root package

--print-changelog
    Display changelogs for updated crates

-h, --help
    Print help information

-V, --version
    Print version

DESCRIPTION

The cargo-update command is a popular Cargo extension that simplifies keeping Rust project dependencies up-to-date by checking crates.io for newer versions of crates listed in your Cargo.lock file and updating them to the latest compatible releases. Unlike the built-in cargo update, which respects exact version constraints in Cargo.toml and only updates within semver-compatible bounds defined there, cargo-update can automatically loosen those constraints to fetch the newest available versions, making it ideal for maintenance tasks.

It supports Cargo workspaces, allowing updates for the root or all members, and provides features like dry runs to preview changes, precise version pinning, and changelog printing for transparency. This helps developers stay current with security patches, bug fixes, and new features without manual intervention. Install via cargo install cargo-update. Always review changes, as major version bumps may introduce breaking changes requiring code adjustments.

CAVEATS

Updating to latest versions may introduce breaking changes; always run --dry-run first and test thoroughly. Requires internet access to crates.io. Not a core Cargo tool—install separately.

INSTALLATION

cargo install cargo-update
Then use as cargo update (overrides built-in).

COMMON USAGE

cargo update -a (full update)
cargo update --dry-run (preview)
cargo update -p rand (single package)

HISTORY

Developed by Kevin Kytola (kbknapp) starting in 2015, cargo-update filled a gap in early Cargo by providing easy 'upgrade all' functionality. Actively maintained, latest versions integrate better with modern Cargo workspaces and semver handling.

SEE ALSO

cargo(1), rustup(1)

Copied to clipboard