1CARGO-CHECK(1)              General Commands Manual             CARGO-CHECK(1)
2
3
4

NAME

6       cargo-check - Check the current package
7

SYNOPSIS

9       cargo check [options]
10

DESCRIPTION

12       Check a local package and all of its dependencies for errors. This will
13       essentially compile the packages without performing the final step of
14       code generation, which is faster than running cargo build. The compiler
15       will save metadata files to disk so that future runs will reuse them if
16       the source has not been modified. Some diagnostics and errors are only
17       emitted during code generation, so they inherently won't be reported
18       with cargo check.
19

OPTIONS

21   Package Selection
22       By default, when no package selection options are given, the packages
23       selected depend on the selected manifest file (based on the current
24       working directory if --manifest-path is not given). If the manifest is
25       the root of a workspace then the workspaces default members are
26       selected, otherwise only the package defined by the manifest will be
27       selected.
28
29       The default members of a workspace can be set explicitly with the
30       workspace.default-members key in the root manifest. If this is not set,
31       a virtual workspace will include all workspace members (equivalent to
32       passing --workspace), and a non-virtual workspace will include only the
33       root crate itself.
34
35       -p spec..., --package spec...
36           Check only the specified packages. See cargo-pkgid(1) for the SPEC
37           format. This flag may be specified multiple times and supports
38           common Unix glob patterns like *, ? and []. However, to avoid your
39           shell accidentally expanding glob patterns before Cargo handles
40           them, you must use single quotes or double quotes around each
41           pattern.
42
43       --workspace
44           Check all members in the workspace.
45
46       --all
47           Deprecated alias for --workspace.
48
49       --exclude SPEC...
50           Exclude the specified packages. Must be used in conjunction with
51           the --workspace flag. This flag may be specified multiple times and
52           supports common Unix glob patterns like *, ? and []. However, to
53           avoid your shell accidentally expanding glob patterns before Cargo
54           handles them, you must use single quotes or double quotes around
55           each pattern.
56
57   Target Selection
58       When no target selection options are given, cargo check will check all
59       binary and library targets of the selected packages. Binaries are
60       skipped if they have required-features that are missing.
61
62       Passing target selection flags will check only the specified targets.
63
64       Note that --bin, --example, --test and --bench flags also support
65       common Unix glob patterns like *, ? and []. However, to avoid your
66       shell accidentally expanding glob patterns before Cargo handles them,
67       you must use single quotes or double quotes around each glob pattern.
68
69       --lib
70           Check the package's library.
71
72       --bin name...
73           Check the specified binary. This flag may be specified multiple
74           times and supports common Unix glob patterns.
75
76       --bins
77           Check all binary targets.
78
79       --example name...
80           Check the specified example. This flag may be specified multiple
81           times and supports common Unix glob patterns.
82
83       --examples
84           Check all example targets.
85
86       --test name...
87           Check the specified integration test. This flag may be specified
88           multiple times and supports common Unix glob patterns.
89
90       --tests
91           Check all targets in test mode that have the test = true manifest
92           flag set. By default this includes the library and binaries built
93           as unittests, and integration tests. Be aware that this will also
94           build any required dependencies, so the lib target may be built
95           twice (once as a unittest, and once as a dependency for binaries,
96           integration tests, etc.). Targets may be enabled or disabled by
97           setting the test flag in the manifest settings for the target.
98
99       --bench name...
100           Check the specified benchmark. This flag may be specified multiple
101           times and supports common Unix glob patterns.
102
103       --benches
104           Check all targets in benchmark mode that have the bench = true
105           manifest flag set. By default this includes the library and
106           binaries built as benchmarks, and bench targets. Be aware that this
107           will also build any required dependencies, so the lib target may be
108           built twice (once as a benchmark, and once as a dependency for
109           binaries, benchmarks, etc.). Targets may be enabled or disabled by
110           setting the bench flag in the manifest settings for the target.
111
112       --all-targets
113           Check all targets. This is equivalent to specifying --lib --bins
114           --tests --benches --examples.
115
116   Feature Selection
117       The feature flags allow you to control which features are enabled. When
118       no feature options are given, the default feature is activated for
119       every selected package.
120
121       See the features documentation
122       <https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options>
123       for more details.
124
125       -F features, --features features
126           Space or comma separated list of features to activate. Features of
127           workspace members may be enabled with package-name/feature-name
128           syntax. This flag may be specified multiple times, which enables
129           all specified features.
130
131       --all-features
132           Activate all available features of all selected packages.
133
134       --no-default-features
135           Do not activate the default feature of the selected packages.
136
137   Compilation Options
138       --target triple
139           Check for the given architecture. The default is the host
140           architecture. The general format of the triple is
141           <arch><sub>-<vendor>-<sys>-<abi>. Run rustc --print target-list for
142           a list of supported targets.
143
144           This may also be specified with the build.target config value
145           <https://doc.rust-lang.org/cargo/reference/config.html>.
146
147           Note that specifying this flag makes Cargo run in a different mode
148           where the target artifacts are placed in a separate directory. See
149           the build cache
150           <https://doc.rust-lang.org/cargo/guide/build-cache.html>
151           documentation for more details.
152
153       -r, --release
154           Check optimized artifacts with the release profile. See also the
155           --profile option for choosing a specific profile by name.
156
157       --profile name
158           Check with the given profile.
159
160           As a special case, specifying the test profile will also enable
161           checking in test mode which will enable checking tests and enable
162           the test cfg option. See rustc tests
163           <https://doc.rust-lang.org/rustc/tests/index.html> for more detail.
164
165           See the the reference
166           <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
167           details on profiles.
168
169       --ignore-rust-version
170           Check the target even if the selected Rust compiler is older than
171           the required Rust version as configured in the project's
172           rust-version field.
173
174       --timings=fmts
175           Output information how long each compilation takes, and track
176           concurrency information over time. Accepts an optional
177           comma-separated list of output formats; --timings without an
178           argument will default to --timings=html. Specifying an output
179           format (rather than the default) is unstable and requires
180           -Zunstable-options. Valid output formats:
181
182html: Write a human-readable file cargo-timing.html to the
183               target/cargo-timings directory with a report of the
184               compilation. Also write a report to the same directory with a
185               timestamp in the filename if you want to look at older runs.
186               HTML output is suitable for human consumption only, and does
187               not provide machine-readable timing data.
188
189json (unstable, requires -Zunstable-options): Emit
190               machine-readable JSON information about timing information.
191
192   Output Options
193       --target-dir directory
194           Directory for all generated artifacts and intermediate files. May
195           also be specified with the CARGO_TARGET_DIR environment variable,
196           or the build.target-dir config value
197           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
198           to target in the root of the workspace.
199
200   Display Options
201       -v, --verbose
202           Use verbose output. May be specified twice for "very verbose"
203           output which includes extra output such as dependency warnings and
204           build script output. May also be specified with the term.verbose
205           config value
206           <https://doc.rust-lang.org/cargo/reference/config.html>.
207
208       -q, --quiet
209           Do not print cargo log messages. May also be specified with the
210           term.quiet config value
211           <https://doc.rust-lang.org/cargo/reference/config.html>.
212
213       --color when
214           Control when colored output is used. Valid values:
215
216auto (default): Automatically detect if color support is
217               available on the terminal.
218
219always: Always display colors.
220
221never: Never display colors.
222
223           May also be specified with the term.color config value
224           <https://doc.rust-lang.org/cargo/reference/config.html>.
225
226       --message-format fmt
227           The output format for diagnostic messages. Can be specified
228           multiple times and consists of comma-separated values. Valid
229           values:
230
231human (default): Display in a human-readable text format.
232               Conflicts with short and json.
233
234short: Emit shorter, human-readable text messages. Conflicts
235               with human and json.
236
237json: Emit JSON messages to stdout. See the reference
238               <https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages>
239               for more details. Conflicts with human and short.
240
241json-diagnostic-short: Ensure the rendered field of JSON
242               messages contains the "short" rendering from rustc. Cannot be
243               used with human or short.
244
245json-diagnostic-rendered-ansi: Ensure the rendered field of JSON
246               messages contains embedded ANSI color codes for respecting
247               rustc's default color scheme. Cannot be used with human or
248               short.
249
250json-render-diagnostics: Instruct Cargo to not include rustc
251               diagnostics in in JSON messages printed, but instead Cargo
252               itself should render the JSON diagnostics coming from rustc.
253               Cargo's own JSON diagnostics and others coming from rustc are
254               still emitted. Cannot be used with human or short.
255
256   Manifest Options
257       --manifest-path path
258           Path to the Cargo.toml file. By default, Cargo searches for the
259           Cargo.toml file in the current directory or any parent directory.
260
261       --frozen, --locked
262           Either of these flags requires that the Cargo.lock file is
263           up-to-date. If the lock file is missing, or it needs to be updated,
264           Cargo will exit with an error. The --frozen flag also prevents
265           Cargo from attempting to access the network to determine if it is
266           out-of-date.
267
268           These may be used in environments where you want to assert that the
269           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
270           network access.
271
272       --offline
273           Prevents Cargo from accessing the network for any reason. Without
274           this flag, Cargo will stop with an error if it needs to access the
275           network and the network is not available. With this flag, Cargo
276           will attempt to proceed without the network if possible.
277
278           Beware that this may result in different dependency resolution than
279           online mode. Cargo will restrict itself to crates that are
280           downloaded locally, even if there might be a newer version as
281           indicated in the local copy of the index. See the cargo-fetch(1)
282           command to download dependencies before going offline.
283
284           May also be specified with the net.offline config value
285           <https://doc.rust-lang.org/cargo/reference/config.html>.
286
287   Common Options
288       +toolchain
289           If Cargo has been installed with rustup, and the first argument to
290           cargo begins with +, it will be interpreted as a rustup toolchain
291           name (such as +stable or +nightly). See the rustup documentation
292           <https://rust-lang.github.io/rustup/overrides.html> for more
293           information about how toolchain overrides work.
294
295       -h, --help
296           Prints help information.
297
298       -Z flag
299           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
300           details.
301
302   Miscellaneous Options
303       -j N, --jobs N
304           Number of parallel jobs to run. May also be specified with the
305           build.jobs config value
306           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
307           to the number of CPUs.
308
309       --keep-going
310           Build as many crates in the dependency graph as possible, rather
311           than aborting the build on the first one that fails to build.
312           Unstable, requires -Zunstable-options.
313
314       --future-incompat-report
315           Displays a future-incompat report for any future-incompatible
316           warnings produced during execution of this command
317
318           See cargo-report(1)
319

ENVIRONMENT

321       See the reference
322       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
323       for details on environment variables that Cargo reads.
324

EXIT STATUS

3260: Cargo succeeded.
327
328101: Cargo failed to complete.
329

EXAMPLES

331        1. Check the local package for errors:
332
333               cargo check
334
335        2. Check all targets, including unit tests:
336
337               cargo check --all-targets --profile=test
338

SEE ALSO

340       cargo(1), cargo-build(1)
341
342
343
344                                                                CARGO-CHECK(1)
Impressum