Rust cargo

ID

cargo

Home page

https://doc.rust-lang.org/cargo/

Version requirement

>= 1

Platforms

🅱️ BSD · 🐧 Linux · 🍎 macOS · ⨂ Unix · 🪟 Windows

Operations

installed · search · install · remove

purl types

pkg:cargo

Brewfile entry

cargo, in Brewfile backups

CLI name

cargo

Every call

cargo --color never --quiet <command>

Issues and PRs

📦 manager: cargo

Source

meta_package_manager/managers/cargo.toml

Rust’s cargo, covering the binaries installed with cargo install.

cargo has no outdated listing and no upgrade command for installed binaries: re-running cargo install is the upstream upgrade story, so neither operation is declared.

What mpm adds to cargo

Through mpm, cargo gains --exact and --extended search, to narrow to exact names or match descriptions.

Bigger still, mpm reaches across every manager at once: mpm installed and mpm outdated cover cargo alongside every other manager you run in one table, mpm upgrade --all updates them together, and mpm sbom exports the whole machine as one bill of materials.

Every mpm command also gains --dry-run and --plan previews, cross-scheme version comparison and purl identifiers. See manager augmentations for how each one is built.

Your cargo commands, in mpm

You already know cargo: each operation maps one-to-one onto mpm, in an interface shared by every manager.

To…

With cargo

With mpm

List what’s installed

cargo install --list

mpm --cargo installed

Search for a package

cargo search --limit 100 <query>

mpm --cargo search <query>

Install a package

cargo install <package_id>

mpm install pkg:cargo/<package_id>

Remove a package

cargo uninstall <package_id>

mpm remove pkg:cargo/<package_id>

Prefix any command above with --dry-run to simulate the underlying manager calls without touching the system: the safe way to watch what mpm would do before trusting it.

Operations

Operation

Supported

Notes

installed

outdated

orphans

search

exact and extended search backfilled by mpm

install

upgrade

upgrade_all

remove

sync

cleanup

doctor

Selecting and configuring cargo

Deselect cargo for a single run with --no-cargo, or persist the choice in your configuration:

[mpm]
cargo = false

The arguments and environment variables listed in the box atop this page are forced on every cargo call, so runs stay quiet, non-interactive and reproducible: the defaults you would set in CI anyway.

Keep it enabled but tune how mpm drives it with a per-manager override:

[mpm.managers.cargo]
timeout = 900

mpm config-template cargo prints every overridable attribute as a ready-to-paste block.

Recipes

A few jobs you would otherwise script around cargo, one mpm command each:

  • Snapshot and clone a machine: mpm --cargo dump cargo.toml, then mpm restore cargo.toml on the next one.

  • Export a Brewfile entry instead: mpm --cargo dump --brewfile Brewfile.

  • Export a compliance SBOM: mpm --cargo sbom (CycloneDX by default, --spdx for SPDX).

Privilege escalation

mpm runs this manager as the current user and never prepends sudo by default. Flip the policy for its privileged operations with --sudo or the per-manager sudo override.

None of its operations needs root.

See privilege escalation for the full policy.

Cooldown

State of Rust cargo’s release-age gating, from the cooldown support table:

  • Status: 🚧 Proposed (RFC 3923 merged, nightly implementation)

  • Mechanism: -Zmin-publish-age

  • Reference: rust-lang/cargo#17009

A cooldown only pays off where a compromised release can be withdrawn while the clock runs, and can only be emulated where the registry dates its releases. From the retraction table:

  • Registry: crates.io (pkg:cargo)

  • Retraction: Yank (cargo yank): “does not delete any data”, and “Cargo will not use a yanked version for any new project or checkout without a pre-existing lockfile”

  • Publish date: ✅ created_at, plus yanked and yank_message (API)

With --cooldown set, mpm skips this manager’s install and upgrade operations rather than run them unguarded (fail-closed); --allow-unsupported-managers opts back in.

Version probe

The version is probed by running:

$ cargo --version
cargo 1.59.0

and extracted with:

r"cargo\s+(?P<version>\S+)"

Reference traces

Raw native outputs captured in the bundled definition: the reference mpm’s parsers were written against. If you know Rust cargo well and a transcript below looks wrong, or a newer release changed its output format, report it.

$ cargo install --list
bore-cli v0.4.0:
    bore
ripgrep v13.0.0:
    rg
$ cargo search --limit 100 {query}
python = "0.0.0"                  # Python.
pyo3 = "0.16.4"                   # Bindings to Python interpreter
... and 1664 crates more (use --limit N to see more)

Feed any of these through mpm and the raw output becomes one uniform table, the same shape for every manager: filter it, project columns, or export it (mpm --cargo installed --output json, or csv, toml, yaml), each package carrying a purl and a version comparable across managers.

Changelog

  • 5.3.0 (2022-06-25)

    • Implement remove operation.

  • 5.1.0 (2022-05-15)

    • Add cargo support. Closes #633.