LinuxCommandLibrary

cargo-version

Display cargo and rustc version information

TLDR

Display version

$ cargo version
copy

Display additional build information
$ cargo version [[-v|--verbose]]
copy

SYNOPSIS

cargo version [OPTIONS]

PARAMETERS

-v, --verbose
    Amount of output:
-v: rustc version, platform, hashes.
-vv+: More dependency/build details.

-q, --quiet
    Suppress cargo version output.

--color WHEN
    Color output control: auto (default), always, never.

--format-version FMT
    Output format: 1 (JSON-like), 2 (default, enhanced).

-Z FLAG
    Unstable nightly flags.

-h, --help
    Print help information.

-V, --version
    Print version (default behavior).

DESCRIPTION

The cargo version command displays version information for the Cargo package manager, essential for Rust developers. By default, it outputs a concise line like cargo 1.75.0 (1d8b05cdd 2023-11-20), helping verify installations quickly.

With -v or multiple -v flags for increased verbosity, it reveals additional details: rustc version (e.g., rustc 1.75.0), platform (e.g., x86_64-unknown-linux-gnu), commit hashes, build configuration, and short/long hash info. This is vital for bug reports, compatibility checks, or scripting.

The --format-version option supports structured output: 1 for legacy JSON-like format or 2 (default) for enhanced human-readable details. It operates offline with no side effects, making it ideal for CI/CD pipelines or shell checks.

Common use cases include pre-flight checks in build scripts or confirming toolchain alignment across systems.

CAVEATS

Verbose output varies by installation (rustup vs. direct). No manifest-path support; global only. Requires Cargo >= 0.10.

EXAMPLES

cargo version
cargo 1.75.0

cargo version -v
cargo 1.75.0
rustc 1.75.0
release: 1.75.0
platform: x86_64-unknown-linux-gnu


cargo version --format-version 1
{"rust_version":"1.75.0","cargo_version":"1.75.0",...}

HISTORY

Debuted in Cargo 0.1 (2014) with Rust 0.10. Verbose mode added early; --format-version in 1.52+ (2021) for scripting. Tracks Rust toolchain evolution.

SEE ALSO

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

Copied to clipboard