cargo
Manage Rust projects and their module dependencies (crates). Some subcommands such as `build` have their own usage documentation.
More info →Subcommands (38)
Add dependencies to a Rust project's `Cargo.toml` manifest.
Compile and execute benchmarks.
Install Rust binaries from CI artifacts. Falls back to `cargo install` (from source code) if there are no binaries available.
Compile a local package and all of its dependencies.
Check a local package and all of its dependencies for errors.
Remove generated artifacts in the `target` directory.
A collection of lints to catch common mistakes and improve your Rust code.
Create Debian packages from Cargo projects.
Build the documentation of Rust packages.
Fetch dependencies of a package from the network.
Automatically fix lint warnings reported by `rustc`.
Run `rustfmt` on all source files in a Rust project.
Display help on `cargo` and its subcommands.
Display information about a Rust package.
Create a new Cargo package. Equivalent of `cargo new`, but specifying a directory is optional.
Build and install a Rust binary.
Save an API token from the registry locally. The token is used to authenticate to a package registry. You can remove it using `cargo logout`.
Remove an API token from the registry locally. The token is used to authenticate to a package registry. You can add it back using `cargo login`.
Output the workspace members and resolved dependencies of current package as JSON. Note: The output format is subject to change in future versions of Cargo.
Manage the Minimum Supported Rust Version (MSRV) of a project.
Create a new Cargo package. Equivalent of `cargo init`, but specifying a directory is required.
Manage the owners of a crate on the registry.
Assemble a local package into a distributable tarball (a `.crate` file). Similar to `cargo publish --dry-run`, but has more options.
Print the fully qualified package ID specifier for a package or dependency in the current workspace.
Upload a package to a registry. Note: You have to add an authentication token using `cargo login` before publishing a package.
Remove dependencies from a Rust project's `Cargo.toml` manifest.
Display various kinds of reports.
Run the current Cargo package. Note: The working directory of the executed binary will be set to the current working directory.
Compile a Rust package. Similar to `cargo build`, but you can pass extra options to the compiler. See `rustc --help` for all available options.
Build the documentation of Rust packages. Similar to `cargo doc`, but you can pass options to `rustdoc`. See `rustdoc --help` for all available options.
Search for packages on <https://crates.io>. The crates are displayed along with descriptions in TOML format suitable for copying into `Cargo.toml`.
Execute the unit and integration tests of a Rust package.
Display a tree visualization of a dependency graph. Note: In the tree, dependencies of packages marked with `(*)` have already been shown elsewhere in the graph, and so are not repeated.
Remove a Rust binary installed globally using `cargo install`.
Update dependencies as recorded in `Cargo.lock`.
Vendor all dependencies of a project into the specified directory (default: `vendor`).
Display `cargo` version information.
Remove a pushed crate from the index. This should only be used when you accidentally release a significantly broken crate. Note: This does not remove any data. The crate is still present after a yank - this just prevents new projects from using it.
Options (3)
booleanBuild the Rust project in the current directory using the release profile
cargo {{[b|build]}} {{[-r|--release]}}-r, --releasebooleanBuild the Rust project in the current directory using the release profile
cargo {{[b|build]}} {{[-r|--release]}}-j, --jobsbooleanBuild using a specific number of threads (default is the number of logical CPUs)
cargo {{[b|build]}} {{[-j|--jobs]}} {{number_of_threads}}Examples (8)
Search for crates
cargo search search_stringInstall a binary crate
cargo install crate_nameList installed binary crates
cargo install --listCreate a new binary or library Rust project in the specified directory (or the current working directory by default)
cargo init --bin|lib path/to/directoryAdd a dependency to `Cargo.toml` in the current directory
cargo add dependencyBuild the Rust project in the current directory using the release profile
cargo [b|build] [-r|--release]Build the Rust project in the current directory using the nightly compiler (requires `rustup`)
cargo +nightly [b|build]Build using a specific number of threads (default is the number of logical CPUs)
cargo [b|build] [-j|--jobs] number_of_threads