cargo 0.38.0

Cargo, a package manager for Rust.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
<h2 id="_name">NAME</h2>
<div class="sectionbody">
<p>cargo - The Rust package manager</p>
</div>
<div class="sect1">
<h2 id="_synopsis">SYNOPSIS</h2>
<div class="sectionbody">
<div class="paragraph">
<p><code>cargo [<em>OPTIONS</em>] <em>COMMAND</em> [<em>ARGS</em>]</code><br>
<code>cargo [<em>OPTIONS</em>] --version</code><br>
<code>cargo [<em>OPTIONS</em>] --list</code><br>
<code>cargo [<em>OPTIONS</em>] --help</code><br>
<code>cargo [<em>OPTIONS</em>] --explain <em>CODE</em></code></p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_description">DESCRIPTION</h2>
<div class="sectionbody">
<div class="paragraph">
<p>This program is a package manager and build tool for the Rust language,
available at <a href="https://rust-lang.org" class="bare">https://rust-lang.org</a>.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_commands">COMMANDS</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_build_commands">Build Commands</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><a href="commands/cargo-bench.html">cargo-bench(1)</a></dt>
<dd>
<p>Execute benchmarks of a package.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-build.html">cargo-build(1)</a></dt>
<dd>
<p>Compile a package.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-check.html">cargo-check(1)</a></dt>
<dd>
<p>Check a local package and all of its dependencies for errors.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-clean.html">cargo-clean(1)</a></dt>
<dd>
<p>Remove artifacts that Cargo has generated in the past.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-doc.html">cargo-doc(1)</a></dt>
<dd>
<p>Build a package&#8217;s documentation.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-fetch.html">cargo-fetch(1)</a></dt>
<dd>
<p>Fetch dependencies of a package from the network.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-fix.html">cargo-fix(1)</a></dt>
<dd>
<p>Automatically fix lint warnings reported by rustc.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-run.html">cargo-run(1)</a></dt>
<dd>
<p>Run a binary or example of the local package.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-rustc.html">cargo-rustc(1)</a></dt>
<dd>
<p>Compile a package, and pass extra options to the compiler.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-rustdoc.html">cargo-rustdoc(1)</a></dt>
<dd>
<p>Build a package&#8217;s documentation, using specified custom flags.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-test.html">cargo-test(1)</a></dt>
<dd>
<p>Execute unit and integration tests of a package.</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="_manifest_commands">Manifest Commands</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><a href="commands/cargo-generate-lockfile.html">cargo-generate-lockfile(1)</a></dt>
<dd>
<p>Generate <code>Cargo.lock</code> for a project.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-locate-project.html">cargo-locate-project(1)</a></dt>
<dd>
<p>Print a JSON representation of a <code>Cargo.toml</code> file&#8217;s location.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-metadata.html">cargo-metadata(1)</a></dt>
<dd>
<p>Output the resolved dependencies of a package, the concrete used versions
including overrides, in machine-readable format.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-pkgid.html">cargo-pkgid(1)</a></dt>
<dd>
<p>Print a fully qualified package specification.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-update.html">cargo-update(1)</a></dt>
<dd>
<p>Update dependencies as recorded in the local lock file.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-verify-project.html">cargo-verify-project(1)</a></dt>
<dd>
<p>Check correctness of crate manifest.</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="_package_commands">Package Commands</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><a href="commands/cargo-init.html">cargo-init(1)</a></dt>
<dd>
<p>Create a new Cargo package in an existing directory.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-install.html">cargo-install(1)</a></dt>
<dd>
<p>Build and install a Rust binary.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-new.html">cargo-new(1)</a></dt>
<dd>
<p>Create a new Cargo package.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-search.html">cargo-search(1)</a></dt>
<dd>
<p>Search packages in crates.io.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-uninstall.html">cargo-uninstall(1)</a></dt>
<dd>
<p>Remove a Rust binary.</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="_publishing_commands">Publishing Commands</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><a href="commands/cargo-login.html">cargo-login(1)</a></dt>
<dd>
<p>Save an API token from the registry locally.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-owner.html">cargo-owner(1)</a></dt>
<dd>
<p>Manage the owners of a crate on the registry.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-package.html">cargo-package(1)</a></dt>
<dd>
<p>Assemble the local package into a distributable tarball.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-publish.html">cargo-publish(1)</a></dt>
<dd>
<p>Upload a package to the registry.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-yank.html">cargo-yank(1)</a></dt>
<dd>
<p>Remove a pushed crate from the index.</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="_general_commands">General Commands</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><a href="commands/cargo-help.html">cargo-help(1)</a></dt>
<dd>
<p>Display help information about Cargo.</p>
</dd>
<dt class="hdlist1"><a href="commands/cargo-version.html">cargo-version(1)</a></dt>
<dd>
<p>Show version information.</p>
</dd>
</dl>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_options">OPTIONS</h2>
<div class="sectionbody">
<div class="sect2">
<h3 id="_special_options">Special Options</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>-V</strong></dt>
<dt class="hdlist1"><strong>--version</strong></dt>
<dd>
<p>Print version info and exit. If used with <code>--verbose</code>, prints extra
information.</p>
</dd>
<dt class="hdlist1"><strong>--list</strong></dt>
<dd>
<p>List all installed Cargo subcommands. If used with <code>--verbose</code>, prints
extra information.</p>
</dd>
<dt class="hdlist1"><strong>--explain <em>CODE</em></strong></dt>
<dd>
<p>Run <code>rustc --explain CODE</code> which will print out a detailed explanation of
an error message (for example, <code>E0004</code>).</p>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="_display_options">Display Options</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>-v</strong></dt>
<dt class="hdlist1"><strong>--verbose</strong></dt>
<dd>
<p>Use verbose output. May be specified twice for "very verbose" output which
includes extra output such as dependency warnings and build script output.
May also be specified with the <code>term.verbose</code>
<a href="reference/config.html">config value</a>.</p>
</dd>
<dt class="hdlist1"><strong>-q</strong></dt>
<dt class="hdlist1"><strong>--quiet</strong></dt>
<dd>
<p>No output printed to stdout.</p>
</dd>
<dt class="hdlist1"><strong>--color</strong> <em>WHEN</em></dt>
<dd>
<p>Control when colored output is used. Valid values:</p>
<div class="ulist">
<ul>
<li>
<p><code>auto</code> (default): Automatically detect if color support is available on the
terminal.</p>
</li>
<li>
<p><code>always</code>: Always display colors.</p>
</li>
<li>
<p><code>never</code>: Never display colors.</p>
</li>
</ul>
</div>
<div class="paragraph">
<p>May also be specified with the <code>term.color</code>
<a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="_manifest_options">Manifest Options</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>--frozen</strong></dt>
<dt class="hdlist1"><strong>--locked</strong></dt>
<dd>
<p>Either of these flags requires that the <code>Cargo.lock</code> file is
up-to-date. If the lock file is missing, or it needs to be updated, Cargo will
exit with an error. The <code>--frozen</code> flag also prevents Cargo from
attempting to access the network to determine if it is out-of-date.</p>
<div class="paragraph">
<p>These may be used in environments where you want to assert that the
<code>Cargo.lock</code> file is up-to-date (such as a CI build) or want to avoid network
access.</p>
</div>
</dd>
<dt class="hdlist1"><strong>--offline</strong></dt>
<dd>
<p>Prevents Cargo from accessing the network for any reason. Without this
flag, Cargo will stop with an error if it needs to access the network and
the network is not available. With this flag, Cargo will attempt to
proceed without the network if possible.</p>
<div class="paragraph">
<p>Beware that this may result in different dependency resolution than online
mode. Cargo will restrict itself to crates that are downloaded locally, even
if there might be a newer version as indicated in the local copy of the index.
See the <a href="commands/cargo-fetch.html">cargo-fetch(1)</a> command to download dependencies before going
offline.</p>
</div>
<div class="paragraph">
<p>May also be specified with the <code>net.offline</code> <a href="reference/config.html">config value</a>.</p>
</div>
</dd>
</dl>
</div>
</div>
<div class="sect2">
<h3 id="_common_options">Common Options</h3>
<div class="dlist">
<dl>
<dt class="hdlist1"><strong>-h</strong></dt>
<dt class="hdlist1"><strong>--help</strong></dt>
<dd>
<p>Prints help information.</p>
</dd>
<dt class="hdlist1"><strong>-Z</strong> <em>FLAG</em>&#8230;&#8203;</dt>
<dd>
<p>Unstable (nightly-only) flags to Cargo. Run <code>cargo -Z help</code> for
details.</p>
</dd>
</dl>
</div>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_environment">ENVIRONMENT</h2>
<div class="sectionbody">
<div class="paragraph">
<p>See <a href="reference/environment-variables.html">the reference</a> for
details on environment variables that Cargo reads.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_exit_status">Exit Status</h2>
<div class="sectionbody">
<div class="dlist">
<dl>
<dt class="hdlist1">0</dt>
<dd>
<p>Cargo succeeded.</p>
</dd>
<dt class="hdlist1">101</dt>
<dd>
<p>Cargo failed to complete.</p>
</dd>
</dl>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_files">FILES</h2>
<div class="sectionbody">
<div class="dlist">
<dl>
<dt class="hdlist1"><code>~/.cargo/</code></dt>
<dd>
<p>Default location for Cargo&#8217;s "home" directory where it stores various
files. The location can be changed with the <code>CARGO_HOME</code> environment
variable.</p>
</dd>
<dt class="hdlist1"><code>$CARGO_HOME/bin/</code></dt>
<dd>
<p>Binaries installed by <a href="commands/cargo-install.html">cargo-install(1)</a> will be located here. If using
rustup, executables distributed with Rust are also located here.</p>
</dd>
<dt class="hdlist1"><code>$CARGO_HOME/config</code></dt>
<dd>
<p>The global configuration file. See <a href="reference/config.html">the reference</a>
for more information about configuration files.</p>
</dd>
<dt class="hdlist1"><code>.cargo/config</code></dt>
<dd>
<p>Cargo automatically searches for a file named <code>.cargo/config</code> in the
current directory, and all parent directories. These configuration files
will be merged with the global configuration file.</p>
</dd>
<dt class="hdlist1"><code>$CARGO_HOME/credentials</code></dt>
<dd>
<p>Private authentication information for logging in to a registry.</p>
</dd>
<dt class="hdlist1"><code>$CARGO_HOME/registry/</code></dt>
<dd>
<p>This directory contains cached downloads of the registry index and any
downloaded dependencies.</p>
</dd>
<dt class="hdlist1"><code>$CARGO_HOME/git/</code></dt>
<dd>
<p>This directory contains cached downloads of git dependencies.</p>
</dd>
</dl>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_examples">EXAMPLES</h2>
<div class="sectionbody">
<div class="olist arabic">
<ol class="arabic">
<li>
<p>Build a local package and all of its dependencies:</p>
<div class="literalblock">
<div class="content">
<pre>cargo build</pre>
</div>
</div>
</li>
<li>
<p>Build a package with optimizations:</p>
<div class="literalblock">
<div class="content">
<pre>cargo build --release</pre>
</div>
</div>
</li>
<li>
<p>Run tests for a cross-compiled target:</p>
<div class="literalblock">
<div class="content">
<pre>cargo test --target i686-unknown-linux-gnu</pre>
</div>
</div>
</li>
<li>
<p>Create a new package that builds an executable:</p>
<div class="literalblock">
<div class="content">
<pre>cargo new foobar</pre>
</div>
</div>
</li>
<li>
<p>Create a package in the current directory:</p>
<div class="literalblock">
<div class="content">
<pre>mkdir foo &amp;&amp; cd foo
cargo init .</pre>
</div>
</div>
</li>
<li>
<p>Learn about a command&#8217;s options and usage:</p>
<div class="literalblock">
<div class="content">
<pre>cargo help clean</pre>
</div>
</div>
</li>
</ol>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_bugs">BUGS</h2>
<div class="sectionbody">
<div class="paragraph">
<p>See <a href="https://github.com/rust-lang/cargo/issues" class="bare">https://github.com/rust-lang/cargo/issues</a> for issues.</p>
</div>
</div>
</div>
<div class="sect1">
<h2 id="_see_also">SEE ALSO</h2>
<div class="sectionbody">
<div class="paragraph">
<p><a href="https://doc.rust-lang.org/rustc/index.html">rustc(1)</a>, <a href="https://doc.rust-lang.org/rustdoc/index.html">rustdoc(1)</a></p>
</div>
</div>
</div>