1CARGO(1)                    General Commands Manual                   CARGO(1)
2
3
4

NAME

6       cargo — The Rust package manager
7

SYNOPSIS

9       cargo [options] command [args]
10       cargo [options] --version
11       cargo [options] --list
12       cargo [options] --help
13       cargo [options] --explain code
14

DESCRIPTION

16       This program is a package manager and build tool for the Rust language,
17       available at <https://rust-lang.org>.
18

COMMANDS

20   Build Commands
21       cargo-bench(1)
22           Execute benchmarks of a package.
23
24       cargo-build(1)
25           Compile a package.
26
27       cargo-check(1)
28           Check a local package and all of its dependencies for errors.
29
30       cargo-clean(1)
31           Remove artifacts that Cargo has generated in the past.
32
33       cargo-doc(1)
34           Build a package’s documentation.
35
36       cargo-fetch(1)
37           Fetch dependencies of a package from the network.
38
39       cargo-fix(1)
40           Automatically fix lint warnings reported by rustc.
41
42       cargo-run(1)
43           Run a binary or example of the local package.
44
45       cargo-rustc(1)
46           Compile a package, and pass extra options to the compiler.
47
48       cargo-rustdoc(1)
49           Build a package’s documentation, using specified custom flags.
50
51       cargo-test(1)
52           Execute unit and integration tests of a package.
53
54   Manifest Commands
55       cargo-generate-lockfile(1)
56           Generate Cargo.lock for a project.
57
58       cargo-locate-project(1)
59           Print a JSON representation of a Cargo.toml file’s location.
60
61       cargo-metadata(1)
62           Output the resolved dependencies of a package in machine-readable
63       format.
64
65       cargo-pkgid(1)
66           Print a fully qualified package specification.
67
68       cargo-tree(1)
69           Display a tree visualization of a dependency graph.
70
71       cargo-update(1)
72           Update dependencies as recorded in the local lock file.
73
74       cargo-vendor(1)
75           Vendor all dependencies locally.
76
77       cargo-verify-project(1)
78           Check correctness of crate manifest.
79
80   Package Commands
81       cargo-init(1)
82           Create a new Cargo package in an existing directory.
83
84       cargo-install(1)
85           Build and install a Rust binary.
86
87       cargo-new(1)
88           Create a new Cargo package.
89
90       cargo-search(1)
91           Search packages in crates.io.
92
93       cargo-uninstall(1)
94           Remove a Rust binary.
95
96   Publishing Commands
97       cargo-login(1)
98           Save an API token from the registry locally.
99
100       cargo-logout(1)
101           Remove an API token from the registry locally.
102
103       cargo-owner(1)
104           Manage the owners of a crate on the registry.
105
106       cargo-package(1)
107           Assemble the local package into a distributable tarball.
108
109       cargo-publish(1)
110           Upload a package to the registry.
111
112       cargo-yank(1)
113           Remove a pushed crate from the index.
114
115   General Commands
116       cargo-help(1)
117           Display help information about Cargo.
118
119       cargo-version(1)
120           Show version information.
121

OPTIONS

123   Special Options
124       -V, --version
125           Print version info and exit. If used with --verbose, prints extra
126           information.
127
128       --list
129           List all installed Cargo subcommands. If used with --verbose,
130           prints extra information.
131
132       --explain code
133           Run rustc --explain CODE which will print out a detailed
134           explanation of an error message (for example, E0004).
135
136   Display Options
137       -v, --verbose
138           Use verbose output. May be specified twice for “very verbose”
139           output which includes extra output such as dependency warnings and
140           build script output. May also be specified with the term.verbose
141           config value
142           <https://doc.rust-lang.org/cargo/reference/config.html>.
143
144       -q, --quiet
145           Do not print cargo log messages. May also be specified with the
146           term.quiet config value
147           <https://doc.rust-lang.org/cargo/reference/config.html>.
148
149       --color when
150           Control when colored output is used. Valid values:
151
152auto (default): Automatically detect if color support is
153               available on the terminal.
154
155always: Always display colors.
156
157never: Never display colors.
158
159           May also be specified with the term.color config value
160           <https://doc.rust-lang.org/cargo/reference/config.html>.
161
162   Manifest Options
163       --frozen, --locked
164           Either of these flags requires that the Cargo.lock file is
165           up-to-date. If the lock file is missing, or it needs to be updated,
166           Cargo will exit with an error. The --frozen flag also prevents
167           Cargo from attempting to access the network to determine if it is
168           out-of-date.
169
170           These may be used in environments where you want to assert that the
171           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
172           network access.
173
174       --offline
175           Prevents Cargo from accessing the network for any reason. Without
176           this flag, Cargo will stop with an error if it needs to access the
177           network and the network is not available. With this flag, Cargo
178           will attempt to proceed without the network if possible.
179
180           Beware that this may result in different dependency resolution than
181           online mode. Cargo will restrict itself to crates that are
182           downloaded locally, even if there might be a newer version as
183           indicated in the local copy of the index. See the cargo-fetch(1)
184           command to download dependencies before going offline.
185
186           May also be specified with the net.offline config value
187           <https://doc.rust-lang.org/cargo/reference/config.html>.
188
189   Common Options
190       +toolchain
191           If Cargo has been installed with rustup, and the first argument to
192           cargo begins with +, it will be interpreted as a rustup toolchain
193           name (such as +stable or +nightly). See the rustup documentation
194           <https://rust-lang.github.io/rustup/overrides.html> for more
195           information about how toolchain overrides work.
196
197       --config KEY=VALUE or PATH
198           Overrides a Cargo configuration value. The argument should be in
199           TOML syntax of KEY=VALUE, or provided as a path to an extra
200           configuration file. This flag may be specified multiple times. See
201           the command-line overrides section
202           <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides>
203           for more information.
204
205       -C PATH
206           Changes the current working directory before executing any
207           specified operations. This affects things like where cargo looks by
208           default for the project manifest (Cargo.toml), as well as the
209           directories searched for discovering .cargo/config.toml, for
210           example. This option must appear before the command name, for
211           example cargo -C path/to/my-project build.
212
213           This option is only available on the nightly channel
214           <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and
215           requires the -Z unstable-options flag to enable (see #10098
216           <https://github.com/rust-lang/cargo/issues/10098>).
217
218       -h, --help
219           Prints help information.
220
221       -Z flag
222           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
223           details.
224

ENVIRONMENT

226       See the reference
227       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
228       for details on environment variables that Cargo reads.
229

EXIT STATUS

2310: Cargo succeeded.
232
233101: Cargo failed to complete.
234

FILES

236       ~/.cargo/
237           Default location for Cargo’s “home” directory where it stores
238       various files. The location can be changed with the CARGO_HOME
239       environment variable.
240
241       $CARGO_HOME/bin/
242           Binaries installed by cargo-install(1) will be located here. If
243       using rustup <https://rust-lang.github.io/rustup/>, executables
244       distributed with Rust are also located here.
245
246       $CARGO_HOME/config.toml
247           The global configuration file. See the reference
248       <https://doc.rust-lang.org/cargo/reference/config.html> for more
249       information about configuration files.
250
251       .cargo/config.toml
252           Cargo automatically searches for a file named .cargo/config.toml in
253       the current directory, and all parent directories. These configuration
254       files will be merged with the global configuration file.
255
256       $CARGO_HOME/credentials.toml
257           Private authentication information for logging in to a registry.
258
259       $CARGO_HOME/registry/
260           This directory contains cached downloads of the registry index and
261       any downloaded dependencies.
262
263       $CARGO_HOME/git/
264           This directory contains cached downloads of git dependencies.
265
266       Please note that the internal structure of the $CARGO_HOME directory is
267       not stable yet and may be subject to change.
268

EXAMPLES

270        1. Build a local package and all of its dependencies:
271
272               cargo build
273
274        2. Build a package with optimizations:
275
276               cargo build --release
277
278        3. Run tests for a cross-compiled target:
279
280               cargo test --target i686-unknown-linux-gnu
281
282        4. Create a new package that builds an executable:
283
284               cargo new foobar
285
286        5. Create a package in the current directory:
287
288               mkdir foo && cd foo
289               cargo init .
290
291        6. Learn about a command’s options and usage:
292
293               cargo help clean
294

BUGS

296       See <https://github.com/rust-lang/cargo/issues> for issues.
297

SEE ALSO

299       rustc(1), rustdoc(1)
300
301
302
303                                                                      CARGO(1)
Impressum