blob: d31221204e01dd75372aadd449d8658bf61e4d40 [file] [log] [blame]
Jeff Vander Stoep956d1432020-09-18 13:46:24 +02001'\" t
2.\" Title: cargo-check
3.\" Author: [see the "AUTHOR(S)" section]
4.\" Generator: Asciidoctor 2.0.10
5.\" Date: 2019-09-05
6.\" Manual: \ \&
7.\" Source: \ \&
8.\" Language: English
9.\"
10.TH "CARGO\-CHECK" "1" "2019-09-05" "\ \&" "\ \&"
11.ie \n(.g .ds Aq \(aq
12.el .ds Aq '
13.ss \n[.ss] 0
14.nh
15.ad l
16.de URL
17\fI\\$2\fP <\\$1>\\$3
18..
19.als MTO URL
20.if \n[.g] \{\
21. mso www.tmac
22. am URL
23. ad l
24. .
25. am MTO
26. ad l
27. .
28. LINKSTYLE blue R < >
29.\}
30.SH "NAME"
31cargo\-check \- Check the current package
32.SH "SYNOPSIS"
33.sp
34\fBcargo check [\fIOPTIONS\fP]\fP
35.SH "DESCRIPTION"
36.sp
37Check a local package and all of its dependencies for errors. This will
38essentially compile the packages without performing the final step of code
39generation, which is faster than running \fBcargo build\fP. The compiler will save
40metadata files to disk so that future runs will reuse them if the source has
41not been modified.
42.SH "OPTIONS"
43.SS "Package Selection"
44.sp
45By default, when no package selection options are given, the packages selected
46depend on the selected manifest file (based on the current working directory if
47\fB\-\-manifest\-path\fP is not given). If the manifest is the root of a workspace then
48the workspaces default members are selected, otherwise only the package defined
49by the manifest will be selected.
50.sp
51The default members of a workspace can be set explicitly with the
52\fBworkspace.default\-members\fP key in the root manifest. If this is not set, a
53virtual workspace will include all workspace members (equivalent to passing
54\fB\-\-workspace\fP), and a non\-virtual workspace will include only the root crate itself.
55.sp
56\fB\-p\fP \fISPEC\fP..., \fB\-\-package\fP \fISPEC\fP...
57.RS 4
58Check only the specified packages. See \fBcargo\-pkgid\fP(1) for the
59SPEC format. This flag may be specified multiple times.
60.RE
61.sp
62\fB\-\-workspace\fP
63.RS 4
64Check all members in the workspace.
65.RE
66.sp
67\fB\-\-all\fP
68.RS 4
69Deprecated alias for \fB\-\-workspace\fP.
70.RE
71.sp
72\fB\-\-exclude\fP \fISPEC\fP...
73.RS 4
74Exclude the specified packages. Must be used in conjunction with the
75\fB\-\-workspace\fP flag. This flag may be specified multiple times.
76.RE
77.SS "Target Selection"
78.sp
79When no target selection options are given, \fBcargo check\fP will check all
80binary and library targets of the selected packages. Binaries are skipped if
81they have \fBrequired\-features\fP that are missing.
82.sp
83Passing target selection flags will check only the
84specified targets.
85.sp
86\fB\-\-lib\fP
87.RS 4
88Check the package\(cqs library.
89.RE
90.sp
91\fB\-\-bin\fP \fINAME\fP...
92.RS 4
93Check the specified binary. This flag may be specified multiple times.
94.RE
95.sp
96\fB\-\-bins\fP
97.RS 4
98Check all binary targets.
99.RE
100.sp
101\fB\-\-example\fP \fINAME\fP...
102.RS 4
103Check the specified example. This flag may be specified multiple times.
104.RE
105.sp
106\fB\-\-examples\fP
107.RS 4
108Check all example targets.
109.RE
110.sp
111\fB\-\-test\fP \fINAME\fP...
112.RS 4
113Check the specified integration test. This flag may be specified multiple
114times.
115.RE
116.sp
117\fB\-\-tests\fP
118.RS 4
119Check all targets in test mode that have the \fBtest = true\fP manifest
120flag set. By default this includes the library and binaries built as
121unittests, and integration tests. Be aware that this will also build any
122required dependencies, so the lib target may be built twice (once as a
123unittest, and once as a dependency for binaries, integration tests, etc.).
124Targets may be enabled or disabled by setting the \fBtest\fP flag in the
125manifest settings for the target.
126.RE
127.sp
128\fB\-\-bench\fP \fINAME\fP...
129.RS 4
130Check the specified benchmark. This flag may be specified multiple times.
131.RE
132.sp
133\fB\-\-benches\fP
134.RS 4
135Check all targets in benchmark mode that have the \fBbench = true\fP
136manifest flag set. By default this includes the library and binaries built
137as benchmarks, and bench targets. Be aware that this will also build any
138required dependencies, so the lib target may be built twice (once as a
139benchmark, and once as a dependency for binaries, benchmarks, etc.).
140Targets may be enabled or disabled by setting the \fBbench\fP flag in the
141manifest settings for the target.
142.RE
143.sp
144\fB\-\-all\-targets\fP
145.RS 4
146Check all targets. This is equivalent to specifying \fB\-\-lib \-\-bins
147\-\-tests \-\-benches \-\-examples\fP.
148.RE
149.SS "Feature Selection"
150.sp
151The feature flags allow you to control the enabled features for the "current"
152package. The "current" package is the package in the current directory, or the
153one specified in \fB\-\-manifest\-path\fP. If running in the root of a virtual
154workspace, then the default features are selected for all workspace members,
155or all features if \fB\-\-all\-features\fP is specified.
156.sp
157When no feature options are given, the \fBdefault\fP feature is activated for
158every selected package.
159.sp
160\fB\-\-features\fP \fIFEATURES\fP
161.RS 4
162Space or comma separated list of features to activate. These features only
163apply to the current directory\(cqs package. Features of direct dependencies
164may be enabled with \fB<dep\-name>/<feature\-name>\fP syntax. This flag may be
165specified multiple times, which enables all specified features.
166.RE
167.sp
168\fB\-\-all\-features\fP
169.RS 4
170Activate all available features of all selected packages.
171.RE
172.sp
173\fB\-\-no\-default\-features\fP
174.RS 4
175Do not activate the \fBdefault\fP feature of the current directory\(cqs
176package.
177.RE
178.SS "Compilation Options"
179.sp
180\fB\-\-target\fP \fITRIPLE\fP
181.RS 4
182Check for the given architecture. The default is the host
183architecture. The general format of the triple is
184\fB<arch><sub>\-<vendor>\-<sys>\-<abi>\fP. Run \fBrustc \-\-print target\-list\fP for a
185list of supported targets.
186.sp
187This may also be specified with the \fBbuild.target\fP
188.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
189.sp
190Note that specifying this flag makes Cargo run in a different mode where the
191target artifacts are placed in a separate directory. See the
192.URL "https://doc.rust\-lang.org/cargo/guide/build\-cache.html" "build cache" " "
193documentation for more details.
194.RE
195.sp
196\fB\-\-release\fP
197.RS 4
198Check optimized artifacts with the \fBrelease\fP profile. See the
199PROFILES section for details on how this affects profile selection.
200.RE
201.sp
202\fB\-\-profile\fP \fINAME\fP
203.RS 4
204Changes check behavior. Currently only \fBtest\fP is
205supported, which will check with the
206\fB#[cfg(test)]\fP attribute enabled. This is useful to have it
207check unit tests which are usually excluded via
208the \fBcfg\fP attribute. This does not change the actual profile used.
209.RE
210.SS "Output Options"
211.sp
212\fB\-\-target\-dir\fP \fIDIRECTORY\fP
213.RS 4
214Directory for all generated artifacts and intermediate files. May also be
215specified with the \fBCARGO_TARGET_DIR\fP environment variable, or the
216\fBbuild.target\-dir\fP \c
217.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
218Defaults
219to \fBtarget\fP in the root of the workspace.
220.RE
221.SS "Display Options"
222.sp
223\fB\-v\fP, \fB\-\-verbose\fP
224.RS 4
225Use verbose output. May be specified twice for "very verbose" output which
226includes extra output such as dependency warnings and build script output.
227May also be specified with the \fBterm.verbose\fP
228.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
229.RE
230.sp
231\fB\-q\fP, \fB\-\-quiet\fP
232.RS 4
233No output printed to stdout.
234.RE
235.sp
236\fB\-\-color\fP \fIWHEN\fP
237.RS 4
238Control when colored output is used. Valid values:
239.sp
240.RS 4
241.ie n \{\
242\h'-04'\(bu\h'+03'\c
243.\}
244.el \{\
245. sp -1
246. IP \(bu 2.3
247.\}
248\fBauto\fP (default): Automatically detect if color support is available on the
249terminal.
250.RE
251.sp
252.RS 4
253.ie n \{\
254\h'-04'\(bu\h'+03'\c
255.\}
256.el \{\
257. sp -1
258. IP \(bu 2.3
259.\}
260\fBalways\fP: Always display colors.
261.RE
262.sp
263.RS 4
264.ie n \{\
265\h'-04'\(bu\h'+03'\c
266.\}
267.el \{\
268. sp -1
269. IP \(bu 2.3
270.\}
271\fBnever\fP: Never display colors.
272.RE
273.sp
274May also be specified with the \fBterm.color\fP
275.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
276.RE
277.sp
278\fB\-\-message\-format\fP \fIFMT\fP
279.RS 4
280The output format for diagnostic messages. Can be specified multiple times
281and consists of comma\-separated values. Valid values:
282.sp
283.RS 4
284.ie n \{\
285\h'-04'\(bu\h'+03'\c
286.\}
287.el \{\
288. sp -1
289. IP \(bu 2.3
290.\}
291\fBhuman\fP (default): Display in a human\-readable text format.
292.RE
293.sp
294.RS 4
295.ie n \{\
296\h'-04'\(bu\h'+03'\c
297.\}
298.el \{\
299. sp -1
300. IP \(bu 2.3
301.\}
302\fBshort\fP: Emit shorter, human\-readable text messages.
303.RE
304.sp
305.RS 4
306.ie n \{\
307\h'-04'\(bu\h'+03'\c
308.\}
309.el \{\
310. sp -1
311. IP \(bu 2.3
312.\}
313\fBjson\fP: Emit JSON messages to stdout. See
314\c
315.URL "https://doc.rust\-lang.org/cargo/reference/external\-tools.html#json\-messages" "the reference"
316for more details.
317.RE
318.sp
319.RS 4
320.ie n \{\
321\h'-04'\(bu\h'+03'\c
322.\}
323.el \{\
324. sp -1
325. IP \(bu 2.3
326.\}
327\fBjson\-diagnostic\-short\fP: Ensure the \fBrendered\fP field of JSON messages contains
328the "short" rendering from rustc.
329.RE
330.sp
331.RS 4
332.ie n \{\
333\h'-04'\(bu\h'+03'\c
334.\}
335.el \{\
336. sp -1
337. IP \(bu 2.3
338.\}
339\fBjson\-diagnostic\-rendered\-ansi\fP: Ensure the \fBrendered\fP field of JSON messages
340contains embedded ANSI color codes for respecting rustc\(cqs default color
341scheme.
342.RE
343.sp
344.RS 4
345.ie n \{\
346\h'-04'\(bu\h'+03'\c
347.\}
348.el \{\
349. sp -1
350. IP \(bu 2.3
351.\}
352\fBjson\-render\-diagnostics\fP: Instruct Cargo to not include rustc diagnostics in
353in JSON messages printed, but instead Cargo itself should render the
354JSON diagnostics coming from rustc. Cargo\(cqs own JSON diagnostics and others
355coming from rustc are still emitted.
356.RE
357.RE
358.SS "Manifest Options"
359.sp
360\fB\-\-manifest\-path\fP \fIPATH\fP
361.RS 4
362Path to the \fBCargo.toml\fP file. By default, Cargo searches for the
363\fBCargo.toml\fP file in the current directory or any parent directory.
364.RE
365.sp
366\fB\-\-frozen\fP, \fB\-\-locked\fP
367.RS 4
368Either of these flags requires that the \fBCargo.lock\fP file is
369up\-to\-date. If the lock file is missing, or it needs to be updated, Cargo will
370exit with an error. The \fB\-\-frozen\fP flag also prevents Cargo from
371attempting to access the network to determine if it is out\-of\-date.
372.sp
373These may be used in environments where you want to assert that the
374\fBCargo.lock\fP file is up\-to\-date (such as a CI build) or want to avoid network
375access.
376.RE
377.sp
378\fB\-\-offline\fP
379.RS 4
380Prevents Cargo from accessing the network for any reason. Without this
381flag, Cargo will stop with an error if it needs to access the network and
382the network is not available. With this flag, Cargo will attempt to
383proceed without the network if possible.
384.sp
385Beware that this may result in different dependency resolution than online
386mode. Cargo will restrict itself to crates that are downloaded locally, even
387if there might be a newer version as indicated in the local copy of the index.
388See the \fBcargo\-fetch\fP(1) command to download dependencies before going
389offline.
390.sp
391May also be specified with the \fBnet.offline\fP \c
392.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
393.RE
394.SS "Common Options"
395.sp
396\fB+TOOLCHAIN\fP
397.RS 4
398If Cargo has been installed with rustup, and the first argument to \fBcargo\fP
399begins with \fB+\fP, it will be interpreted as a rustup toolchain name (such
400as \fB+stable\fP or \fB+nightly\fP).
401See the \c
402.URL "https://github.com/rust\-lang/rustup/" "rustup documentation"
403for more information about how toolchain overrides work.
404.RE
405.sp
406\fB\-h\fP, \fB\-\-help\fP
407.RS 4
408Prints help information.
409.RE
410.sp
411\fB\-Z\fP \fIFLAG\fP...
412.RS 4
413Unstable (nightly\-only) flags to Cargo. Run \fBcargo \-Z help\fP for
414details.
415.RE
416.SS "Miscellaneous Options"
417.sp
418\fB\-j\fP \fIN\fP, \fB\-\-jobs\fP \fIN\fP
419.RS 4
420Number of parallel jobs to run. May also be specified with the
421\fBbuild.jobs\fP \c
422.URL "https://doc.rust\-lang.org/cargo/reference/config.html" "config value" "."
423Defaults to
424the number of CPUs.
425.RE
426.SH "PROFILES"
427.sp
428Profiles may be used to configure compiler options such as optimization levels
429and debug settings. See
430\c
431.URL "https://doc.rust\-lang.org/cargo/reference/profiles.html" "the reference"
432for more details.
433.sp
434Profile selection depends on the target and crate being built. By default the
435\fBdev\fP or \fBtest\fP profiles are used. If the \fB\-\-release\fP flag is given, then the
436\fBrelease\fP or \fBbench\fP profiles are used.
437.TS
438allbox tab(:);
439lt lt lt.
440T{
441.sp
442Target
443T}:T{
444.sp
445Default Profile
446T}:T{
447.sp
448\fB\-\-release\fP Profile
449T}
450T{
451.sp
452lib, bin, example
453T}:T{
454.sp
455\fBdev\fP
456T}:T{
457.sp
458\fBrelease\fP
459T}
460T{
461.sp
462test, bench, or any target
463.br
464in "test" or "bench" mode
465T}:T{
466.sp
467\fBtest\fP
468T}:T{
469.sp
470\fBbench\fP
471T}
472.TE
473.sp
474.sp
475Dependencies use the \fBdev\fP/\fBrelease\fP profiles.
476.SH "ENVIRONMENT"
477.sp
478See \c
479.URL "https://doc.rust\-lang.org/cargo/reference/environment\-variables.html" "the reference" " "
480for
481details on environment variables that Cargo reads.
482.SH "EXIT STATUS"
483.sp
4840
485.RS 4
486Cargo succeeded.
487.RE
488.sp
489101
490.RS 4
491Cargo failed to complete.
492.RE
493.SH "EXAMPLES"
494.sp
495.RS 4
496.ie n \{\
497\h'-04' 1.\h'+01'\c
498.\}
499.el \{\
500. sp -1
501. IP " 1." 4.2
502.\}
503Check the local package for errors:
504.sp
505.if n .RS 4
506.nf
507cargo check
508.fi
509.if n .RE
510.RE
511.sp
512.RS 4
513.ie n \{\
514\h'-04' 2.\h'+01'\c
515.\}
516.el \{\
517. sp -1
518. IP " 2." 4.2
519.\}
520Check all targets, including unit tests:
521.sp
522.if n .RS 4
523.nf
524cargo check \-\-all\-targets \-\-profile=test
525.fi
526.if n .RE
527.RE
528.SH "SEE ALSO"
529.sp
530\fBcargo\fP(1), \fBcargo\-build\fP(1)