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       -h, --help
195           Prints help information.
196
197       -Z flag
198           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
199           details.
200

ENVIRONMENT

202       See the reference
203       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
204       for details on environment variables that Cargo reads.
205

EXIT STATUS

2070: Cargo succeeded.
208
209101: Cargo failed to complete.
210

FILES

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

EXAMPLES

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

BUGS

272       See <https://github.com/rust-lang/cargo/issues> for issues.
273

SEE ALSO

275       rustc(1), rustdoc(1)
276
277
278
279                                                                      CARGO(1)
Impressum