1CARGO(1) CARGO(1)
2
3
4
6 cargo - The Rust package manager
7
9 cargo [OPTIONS] COMMAND [ARGS]
10 cargo [OPTIONS] --version
11 cargo [OPTIONS] --list
12 cargo [OPTIONS] --help
13 cargo [OPTIONS] --explain CODE
14
16 This program is a package manager and build tool for the Rust language,
17 available at https://rust-lang.org.
18
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, the concrete used
63 versions including overrides, in machine-readable format.
64
65 cargo-pkgid(1)
66 Print a fully qualified package specification.
67
68 cargo-update(1)
69 Update dependencies as recorded in the local lock file.
70
71 cargo-verify-project(1)
72 Check correctness of crate manifest.
73
74 Package Commands
75 cargo-init(1)
76 Create a new Cargo package in an existing directory.
77
78 cargo-install(1)
79 Build and install a Rust binary.
80
81 cargo-new(1)
82 Create a new Cargo package.
83
84 cargo-search(1)
85 Search packages in crates.io.
86
87 cargo-uninstall(1)
88 Remove a Rust binary.
89
90 Publishing Commands
91 cargo-login(1)
92 Save an API token from the registry locally.
93
94 cargo-owner(1)
95 Manage the owners of a crate on the registry.
96
97 cargo-package(1)
98 Assemble the local package into a distributable tarball.
99
100 cargo-publish(1)
101 Upload a package to the registry.
102
103 cargo-yank(1)
104 Remove a pushed crate from the index.
105
106 General Commands
107 cargo-help(1)
108 Display help information about Cargo.
109
110 cargo-version(1)
111 Show version information.
112
114 Special Options
115 -V, --version
116 Print version info and exit. If used with --verbose, prints extra
117 information.
118
119 --list
120 List all installed Cargo subcommands. If used with --verbose,
121 prints extra information.
122
123 --explain CODE
124 Run rustc --explain CODE which will print out a detailed
125 explanation of an error message (for example, E0004).
126
127 Display Options
128 -v, --verbose
129 Use verbose output. May be specified twice for "very verbose"
130 output which includes extra output such as dependency warnings and
131 build script output. May also be specified with the term.verbose
132 config value
133 <https://doc.rust-lang.org/cargo/reference/config.html>.
134
135 -q, --quiet
136 No output printed to stdout.
137
138 --color WHEN
139 Control when colored output is used. Valid values:
140
141 · auto (default): Automatically detect if color support is
142 available on the terminal.
143
144 · always: Always display colors.
145
146 · never: Never display colors.
147
148 May also be specified with the term.color config value
149 <https://doc.rust-lang.org/cargo/reference/config.html>.
150
151 Manifest Options
152 --frozen, --locked
153 Either of these flags requires that the Cargo.lock file is
154 up-to-date. If the lock file is missing, or it needs to be updated,
155 Cargo will exit with an error. The --frozen flag also prevents
156 Cargo from attempting to access the network to determine if it is
157 out-of-date.
158
159 These may be used in environments where you want to assert that the
160 Cargo.lock file is up-to-date (such as a CI build) or want to avoid
161 network access.
162
163 --offline
164 Prevents Cargo from accessing the network for any reason. Without
165 this flag, Cargo will stop with an error if it needs to access the
166 network and the network is not available. With this flag, Cargo
167 will attempt to proceed without the network if possible.
168
169 Beware that this may result in different dependency resolution than
170 online mode. Cargo will restrict itself to crates that are
171 downloaded locally, even if there might be a newer version as
172 indicated in the local copy of the index. See the cargo-fetch(1)
173 command to download dependencies before going offline.
174
175 May also be specified with the net.offline config value
176 <https://doc.rust-lang.org/cargo/reference/config.html>.
177
178 Common Options
179 -h, --help
180 Prints help information.
181
182 -Z FLAG...
183 Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
184 details.
185
187 See the reference
188 <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
189 for details on environment variables that Cargo reads.
190
192 0
193 Cargo succeeded.
194
195 101
196 Cargo failed to complete.
197
199 ~/.cargo/
200 Default location for Cargo’s "home" directory where it stores
201 various files. The location can be changed with the CARGO_HOME
202 environment variable.
203
204 $CARGO_HOME/bin/
205 Binaries installed by cargo-install(1) will be located here. If
206 using rustup, executables distributed with Rust are also located
207 here.
208
209 $CARGO_HOME/config
210 The global configuration file. See the reference
211 <https://doc.rust-lang.org/cargo/reference/config.html> for more
212 information about configuration files.
213
214 .cargo/config
215 Cargo automatically searches for a file named .cargo/config in the
216 current directory, and all parent directories. These configuration
217 files will be merged with the global configuration file.
218
219 $CARGO_HOME/credentials
220 Private authentication information for logging in to a registry.
221
222 $CARGO_HOME/registry/
223 This directory contains cached downloads of the registry index and
224 any downloaded dependencies.
225
226 $CARGO_HOME/git/
227 This directory contains cached downloads of git dependencies.
228
229 Please note that the internal structure of the $CARGO_HOME directory is
230 not stable yet and may be subject to change.
231
233 1. Build a local package and all of its dependencies:
234
235 cargo build
236
237 2. Build a package with optimizations:
238
239 cargo build --release
240
241 3. Run tests for a cross-compiled target:
242
243 cargo test --target i686-unknown-linux-gnu
244
245 4. Create a new package that builds an executable:
246
247 cargo new foobar
248
249 5. Create a package in the current directory:
250
251 mkdir foo && cd foo
252 cargo init .
253
254 6. Learn about a command’s options and usage:
255
256 cargo help clean
257
259 See https://github.com/rust-lang/cargo/issues for issues.
260
262 rustc(1), rustdoc(1)
263
264
265
266 2019-09-05 CARGO(1)