Cargo subcommands worth knowing¶
Level: 201 · working knowledge
One line: Any program named cargo-something on your PATH becomes cargo something — so most of Cargo's ecosystem is installed rather than built in, and a dozen of those programs answer questions cargo alone cannot.
Stub — an outline, not a lesson. There is no runnable example behind this page yet, so nothing on it has been through the check that backs every other claim in this library. The bullets below are the questions the finished page has to answer.
What it has to cover¶
- The mechanism: how
cargo foofindscargo-foo, andcargo --list - Which ones answer which question, one line each and run once on a real project:
cargo-expand(what did the macros write?),cargo-udeps/cargo-machete(which dependency is unused?),cargo-deny/cargo-audit(licences and advisories),cargo-bloat/cargo-llvm-lines(what makes the binary big and the build slow?),cargo-hack(every feature combination),cargo-semver-checks(did I break my API?) - What moved into Cargo itself:
cargo addandcargo remove, formerlycargo-edit cargo installvscargo binstall,--locked, and where the binaries go- Which of these need nightly (
cargo-udepsdoes, as of its last release — verify) - Tools this library already covers: bacon, cargo-nextest,
cargo vendor
The trap it exists for¶
cargo install without --locked. It ignores the tool's own Cargo.lock and resolves fresh dependency versions, so a tool that built yesterday can fail today. The Cargo.lock page shows the command and why.
Where this sits¶
Tooling has a page for each tool this library has measured. This page is the index of the ones it has not, sorted by the question each answers. Rust for Rustaceans ch. 13 "The Rust Ecosystem" lists many of the same tools.
See also¶
Cargo.lock— whycargo installwants--locked- bacon — a subcommand-shaped tool, measured
- cargo-nextest — another, measured
- Expanding a macro —
cargo expandin use - Cargo features —
cargo hack --feature-powerset - TOOLCHAIN.md — the toolchain pages by problem
If you are coming from another language¶
- Git. The same plug-in rule: an executable named
git-foobecomesgit foo, which is where Cargo borrowed it from. - Python. There is no single entry point, so the equivalents are separate commands:
pip-audit,deptry,vulture. Theuv tool install/pipxsplit mirrorscargo install. - Go.
go vetandgovulncheckcover part of this list; the rest are separate binaries installed withgo install.
Po polsku¶
Każdy program o nazwie cargo-coś leżący na PATH staje się poleceniem cargo coś — dlatego większość ekosystemu Cargo się instaluje, a nie jest wbudowana. Instaluj z --locked, bo bez tego cargo install ignoruje Cargo.lock narzędzia i potrafi dziś nie zbudować tego, co wczoraj działało.
Szukaj po polsku: podpolecenia Cargo · narzędzia Cargo · cargo install locked · useful cargo subcommands