LinuxCommandLibrary

cargo-search

Search crates.io for crates by keyword

TLDR

Search for packages

$ cargo search [query]
copy

Show n results (default: 10, max: 100)
$ cargo search --limit [n] [query]
copy

SYNOPSIS

cargo search [OPTIONS] [<QUERY>]

PARAMETERS

--index <INDEX_URL>
    URL of the registry index to use

--limit <LIMIT>
    Limit number of results (default: 10, max: 100)

-q, --quiet
    No output printed to stdout

-v, --verbose ...
    Use verbose output (-vv very verbose)

--color <WHEN>
    Configure coloring of output

-h, --help
    Print help information

-V, --version
    Print version information

<QUERY>
    Search string matching crate name or description

DESCRIPTION

The cargo search command is a subcommand of Cargo, Rust's package manager, used to query the central package registry at crates.io for available crates (Rust libraries or binaries). It allows developers to discover packages by searching crate names and descriptions.

Executing cargo search <query> returns a formatted list of matching crates, including name, description, recent downloads, and version. Results are relevance-sorted, with a default limit of 10 (maximum 100 via --limit). This is ideal for quick package discovery before installation via cargo install or addition to Cargo.toml.

The command fetches data from the registry index, supporting alternative registries with --index. It respects Cargo's configuration for proxies, credentials, and verbosity. Output is colorized by default for readability, showing metrics like #downloads to gauge popularity.

Common use cases include finding algorithmic crates (cargo search sort), web frameworks (cargo search actix), or dependencies for specific needs. It's lightweight, network-dependent, and integrates seamlessly with other Cargo workflows.

CAVEATS

Requires network access to registry; max 100 results; case-insensitive but relevance-based; no exact keyword matching.

EXAMPLES

cargo search rand (finds random number crates)
cargo search --limit 20 tokio (async runtime crates)

OUTPUT FORMAT

Each result shows: crate = version #downloads description

HISTORY

Introduced in Cargo 0.6.0 (March 2015) as part of early Cargo stabilization. Enhanced in later versions for better index support and limits (e.g., Cargo 1.0+). Actively maintained within Rust toolchain.

SEE ALSO

cargo install(1), cargo info(1), apt-cache search(8), dnf search(8)

Copied to clipboard