LinuxCommandLibrary

cargo-msrv

Determine project's minimum Rust version

TLDR

Display the MSRVs of dependencies (as specified in their Cargo.toml)

$ cargo msrv list
copy

Find the MSRV of the project by trying to compile it with various toolchains
$ cargo msrv find
copy

Show the MSRV of the project as specified in Cargo.toml
$ cargo msrv show
copy

Set the MSRV in Cargo.toml to a given Rust version
$ cargo msrv set [version]
copy

Verify whether the MSRV is satisfiable by compiling the project using the specified version of Rust
$ cargo msrv verify
copy

SYNOPSIS

cargo msrv [SUBCOMMAND] [OPTIONS] [--] <COMMAND>

PARAMETERS

-h, --help
    Prints help information

-V, --version
    Prints version information

--baseline RUST_VERSION
    Sets the baseline (oldest) Rust version to consider in searches (default: project's declared MSRV or 1.31.0)

--commit-hash HASH
    Uses a specific Rust commit hash instead of version

--rustc-revision REVISION
    Specifies nightly Rust revision

--host-triple TRIPLE
    Host triple for toolchain installation (default: from rustup)

--target-triple TRIPLES
    Target triples for building

--profile PROFILE
    Build profile like 'dev' or 'release' (default: dev)

--jobs N
    Number of parallel jobs

-y, --yes
    Auto-confirm prompts

--locked
    Do not update Cargo.lock

--frozen
    Require Cargo.lock and cache are up to date

--manifest-path PATH
    Path to Cargo.toml

-v
    Verbose output

-q
    No output printed to stdout

--dry-run
    Simulate without installing toolchains or building

DESCRIPTION

Cargo-msrv is a powerful Cargo subcommand designed to help Rust developers determine, verify, and manage the Minimum Supported Rust Version (MSRV) for their projects. It performs a binary search over Rust toolchain versions to find the oldest version capable of building the project successfully, ensuring compatibility declarations (e.g., in Cargo.toml or README.md) are accurate.

Key use cases include libraries maintaining an MSRV policy to support stable Rust releases without breaking changes, CI integration for automated verification, and updating MSRVs during dependency upgrades. It integrates with rustup to install and test multiple Rust versions on-the-fly, running custom Cargo commands like build, test, or check against them.

The tool supports workspace projects, custom profiles, feature flags, cross-compilation triples, and more, making it essential for robust Rust ecosystem tooling. It outputs clear reports on pass/fail versions and can pin or update MSRVs automatically.

CAVEATS

Requires rustup installed; downloads multiple Rust versions (use --no-install to avoid); may fail on projects with unstable features or non-standard build scripts; not for production builds.

COMMON SUBCOMMANDS

verify: Checks if declared MSRV builds project.
resolve: Finds lowest working Rust version.
update: Updates MSRV to resolved version.
pin: Pins MSRV in Cargo.toml.
Example: cargo msrv verify -- build

INSTALLATION

Run cargo install cargo-msrv (requires Rust toolchain). Verify with cargo msrv --version.

HISTORY

Developed by Matthias Endler starting in 2020 as 'msrv', evolved into cargo-msrv for seamless Cargo integration. Gained popularity in Rust community for MSRV policies; latest versions (0.10+) add workspace support, better CI integration, and nightly handling.

SEE ALSO

cargo(1), rustup(1), rustc(1)

Copied to clipboard