Handy cheat sheet for Rust package manager Cargo (cargo
)
Based on Cargo version:
$ cargo --version cargo 1.29.0 (524a578d7 2018-08-05)
Usage
|
Shows version information, hash and date, see also the introduction above |
|
Lists all installed and available commands |
|
Enable verbose output. Shorthand -v and -vv for more (very) verbose output |
|
Disable output on STDOUT |
|
Enable colours, auto, always or never |
|
Shows help message |
|
Require Cargo.lock is up to date |
|
Require Cargo.lock and cache are up to date is up to date |
|
Unstable (nightly-only) flags to Cargo, see "cargo -Z help" for details for further information on unstable flags |
|
Executes |
Start a Rust Project
|
Create new application/executable based project |
|
Create new library based project, this is actually the default and |
|
Initialize a new application/executable in current directory |
|
Initialize a library in current directory |
Build a Rust Project
|
Build a Rust project |
|
Build a Rust project in parallel with mutiple jobs |
|
Executes benchmark of project, requires tests |
|
Executes benchmark of project, requires tests |
|
Analyze the current project and report possible errors, but does not build object files |
|
Executes project tests, requires tests |
|
Builds projects documentation, requires inlines documentation in source files |
|
Clean out the build, by removing the target/ directory |
Maintain a Rust Project
|
Search for crates |
|
Install a Rust binary |
|
Install a named crate, see search above |
|
Lists installed crates |
|
Lists installed crates |
Maintain a Rust Crate
|
Package this project into a distributable tarball |
|
Upload a package to the registry |
|
Remove a pushed crate from the index |
Environment Variables
|
Cargo maintains a local cache of the registry index and of git checkouts of crates. By default these are stored under |
|
Location of where to place generated artifacts, relative to the current working directory |
|
Instead of running rustc, Cargo will execute specified compiler instead |
|
Instead of running rustc, Cargo will execute specified wrapper instead, passing as its commandline arguments the rustc invocation, with the first argument being rustc |
|
Instead of running rustdoc, Cargo will execute specified rustdoc instance |
|
A space-separated list of custom flags to pass to rustdoc invocations that Cargo performs. In contrast to cargo rustdoc, this is useful for passing a flag to all rustdoc instances |
|
A space-separated list of custom flags to pass to compiler invocations that Cargo performs. In contrast to cargo rustc, this is useful for passing a flag to all compiler instances |
|
If set to 1 then Cargo will force incremental compilation to be enabled for the current compilation, and when set to 0 it will force disabling it. If this env var is not present then Cargo defaults will be used |
|
If set to 0 then Cargo will not attempt to cache compiler version information |
Notes
- For more information on Cargo see the official documentation
- For more information on the Cargo environment variables see the official documentation
- For access to the Cargo source code, visit the repository on GitHub