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-owner(1)
101           Manage the owners of a crate on the registry.
102
103       cargo-package(1)
104           Assemble the local package into a distributable tarball.
105
106       cargo-publish(1)
107           Upload a package to the registry.
108
109       cargo-yank(1)
110           Remove a pushed crate from the index.
111
112   General Commands
113       cargo-help(1)
114           Display help information about Cargo.
115
116       cargo-version(1)
117           Show version information.
118

OPTIONS

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

ENVIRONMENT

210       See the reference
211       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
212       for details on environment variables that Cargo reads.
213

EXIT STATUS

2150: Cargo succeeded.
216
217101: Cargo failed to complete.
218

FILES

220       ~/.cargo/
221           Default location for Cargo's "home" directory where it stores
222       various files. The location can be changed with the CARGO_HOME
223       environment variable.
224
225       $CARGO_HOME/bin/
226           Binaries installed by cargo-install(1) will be located here. If
227       using rustup <https://rust-lang.github.io/rustup/>, executables
228       distributed with Rust are also located here.
229
230       $CARGO_HOME/config.toml
231           The global configuration file. See the reference
232       <https://doc.rust-lang.org/cargo/reference/config.html> for more
233       information about configuration files.
234
235       .cargo/config.toml
236           Cargo automatically searches for a file named .cargo/config.toml in
237       the current directory, and all parent directories. These configuration
238       files will be merged with the global configuration file.
239
240       $CARGO_HOME/credentials.toml
241           Private authentication information for logging in to a registry.
242
243       $CARGO_HOME/registry/
244           This directory contains cached downloads of the registry index and
245       any downloaded dependencies.
246
247       $CARGO_HOME/git/
248           This directory contains cached downloads of git dependencies.
249
250       Please note that the internal structure of the $CARGO_HOME directory is
251       not stable yet and may be subject to change.
252

EXAMPLES

254        1. Build a local package and all of its dependencies:
255
256               cargo build
257
258        2. Build a package with optimizations:
259
260               cargo build --release
261
262        3. Run tests for a cross-compiled target:
263
264               cargo test --target i686-unknown-linux-gnu
265
266        4. Create a new package that builds an executable:
267
268               cargo new foobar
269
270        5. Create a package in the current directory:
271
272               mkdir foo && cd foo
273               cargo init .
274
275        6. Learn about a command's options and usage:
276
277               cargo help clean
278

BUGS

280       See <https://github.com/rust-lang/cargo/issues> for issues.
281

SEE ALSO

283       rustc(1), rustdoc(1)
284
285
286
287                                                                      CARGO(1)
Impressum