5 cargo --- The Rust package manager
9 `cargo` [_options_] _command_ [_args_]\
10 `cargo` [_options_] `--version`\
11 `cargo` [_options_] `--list`\
12 `cargo` [_options_] `--help`\
13 `cargo` [_options_] `--explain` _code_
17 This program is a package manager and build tool for the Rust language,
18 available at <https://rust-lang.org>.
24 {{man "cargo-bench" 1}}\
25 Execute benchmarks of a package.
27 {{man "cargo-build" 1}}\
28 Compile a package.
30 {{man "cargo-check" 1}}\
31 Check a local package and all of its dependencies for errors.
33 {{man "cargo-clean" 1}}\
34 Remove artifacts that Cargo has generated in the past.
36 {{man "cargo-doc" 1}}\
37 Build a package's documentation.
39 {{man "cargo-fetch" 1}}\
40 Fetch dependencies of a package from the network.
42 {{man "cargo-fix" 1}}\
43 Automatically fix lint warnings reported by rustc.
45 {{man "cargo-run" 1}}\
46 Run a binary or example of the local package.
48 {{man "cargo-rustc" 1}}\
49 Compile a package, and pass extra options to the compiler.
51 {{man "cargo-rustdoc" 1}}\
52 Build a package's documentation, using specified custom flags.
54 {{man "cargo-test" 1}}\
55 Execute unit and integration tests of a package.
59 {{man "cargo-generate-lockfile" 1}}\
60 Generate `Cargo.lock` for a project.
62 {{man "cargo-locate-project" 1}}\
63 Print a JSON representation of a `Cargo.toml` file's location.
65 {{man "cargo-metadata" 1}}\
66 Output the resolved dependencies of a package in machine-readable format.
68 {{man "cargo-pkgid" 1}}\
69 Print a fully qualified package specification.
71 {{man "cargo-tree" 1}}\
72 Display a tree visualization of a dependency graph.
74 {{man "cargo-update" 1}}\
75 Update dependencies as recorded in the local lock file.
77 {{man "cargo-vendor" 1}}\
78 Vendor all dependencies locally.
80 {{man "cargo-verify-project" 1}}\
81 Check correctness of crate manifest.
85 {{man "cargo-init" 1}}\
86 Create a new Cargo package in an existing directory.
88 {{man "cargo-install" 1}}\
89 Build and install a Rust binary.
91 {{man "cargo-new" 1}}\
92 Create a new Cargo package.
94 {{man "cargo-search" 1}}\
95 Search packages in crates.io.
97 {{man "cargo-uninstall" 1}}\
98 Remove a Rust binary.
100 ### Publishing Commands
102 {{man "cargo-login" 1}}\
103 Save an API token from the registry locally.
105 {{man "cargo-logout" 1}}\
106 Remove an API token from the registry locally.
108 {{man "cargo-owner" 1}}\
109 Manage the owners of a crate on the registry.
111 {{man "cargo-package" 1}}\
112 Assemble the local package into a distributable tarball.
114 {{man "cargo-publish" 1}}\
115 Upload a package to the registry.
117 {{man "cargo-yank" 1}}\
118 Remove a pushed crate from the index.
122 {{man "cargo-help" 1}}\
123 Display help information about Cargo.
125 {{man "cargo-version" 1}}\
126 Show version information.
134 {{#option "`-V`" "`--version`" }}
135 Print version info and exit. If used with `--verbose`, prints extra
139 {{#option "`--list`" }}
140 List all installed Cargo subcommands. If used with `--verbose`, prints extra
144 {{#option "`--explain` _code_" }}
145 Run `rustc --explain CODE` which will print out a detailed explanation of an
146 error message (for example, `E0004`).
155 {{> options-display }}
162 {{> options-locked }}
165 {{> section-options-common }}
167 {{> section-environment }}
169 {{> section-exit-status }}
174 Default location for Cargo's "home" directory where it
175 stores various files. The location can be changed with the `CARGO_HOME`
176 environment variable.
179 Binaries installed by {{man "cargo-install" 1}} will be located here. If using
180 [rustup], executables distributed with Rust are also located here.
182 `$CARGO_HOME/config.toml`\
183 The global configuration file. See [the reference](../reference/config.html)
184 for more information about configuration files.
186 `.cargo/config.toml`\
187 Cargo automatically searches for a file named `.cargo/config.toml` in the
188 current directory, and all parent directories. These configuration files
189 will be merged with the global configuration file.
191 `$CARGO_HOME/credentials.toml`\
192 Private authentication information for logging in to a registry.
194 `$CARGO_HOME/registry/`\
195 This directory contains cached downloads of the registry index and any
196 downloaded dependencies.
199 This directory contains cached downloads of git dependencies.
201 Please note that the internal structure of the `$CARGO_HOME` directory is not
202 stable yet and may be subject to change.
204 [rustup]: https://rust-lang.github.io/rustup/
208 1. Build a local package and all of its dependencies:
212 2. Build a package with optimizations:
214 cargo build --release
216 3. Run tests for a cross-compiled target:
218 cargo test --target i686-unknown-linux-gnu
220 4. Create a new package that builds an executable:
224 5. Create a package in the current directory:
229 6. Learn about a command's options and usage:
235 See <https://github.com/rust-lang/cargo/issues> for issues.
238 {{man "rustc" 1}}, {{man "rustdoc" 1}}