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       --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       --release
154           Check optimized artifacts with the release profile. See the
155           PROFILES section for details on how this affects profile selection.
156
157       --profile name
158           Changes check behavior. Currently only test is supported, which
159           will check with the #[cfg(test)] attribute enabled. This is useful
160           to have it check unit tests which are usually excluded via the cfg
161           attribute. This does not change the actual profile used.
162
163       --ignore-rust-version
164           Check the target even if the selected Rust compiler is older than
165           the required Rust version as configured in the project's
166           rust-version field.
167
168   Output Options
169       --target-dir directory
170           Directory for all generated artifacts and intermediate files. May
171           also be specified with the CARGO_TARGET_DIR environment variable,
172           or the build.target-dir config value
173           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
174           to target in the root of the workspace.
175
176   Display Options
177       -v, --verbose
178           Use verbose output. May be specified twice for "very verbose"
179           output which includes extra output such as dependency warnings and
180           build script output. May also be specified with the term.verbose
181           config value
182           <https://doc.rust-lang.org/cargo/reference/config.html>.
183
184       -q, --quiet
185           No output printed to stdout.
186
187       --color when
188           Control when colored output is used. Valid values:
189
190auto (default): Automatically detect if color support is
191               available on the terminal.
192
193always: Always display colors.
194
195never: Never display colors.
196
197           May also be specified with the term.color config value
198           <https://doc.rust-lang.org/cargo/reference/config.html>.
199
200       --message-format fmt
201           The output format for diagnostic messages. Can be specified
202           multiple times and consists of comma-separated values. Valid
203           values:
204
205human (default): Display in a human-readable text format.
206               Conflicts with short and json.
207
208short: Emit shorter, human-readable text messages. Conflicts
209               with human and json.
210
211json: Emit JSON messages to stdout. See the reference
212               <https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages>
213               for more details. Conflicts with human and short.
214
215json-diagnostic-short: Ensure the rendered field of JSON
216               messages contains the "short" rendering from rustc. Cannot be
217               used with human or short.
218
219json-diagnostic-rendered-ansi: Ensure the rendered field of JSON
220               messages contains embedded ANSI color codes for respecting
221               rustc's default color scheme. Cannot be used with human or
222               short.
223
224json-render-diagnostics: Instruct Cargo to not include rustc
225               diagnostics in in JSON messages printed, but instead Cargo
226               itself should render the JSON diagnostics coming from rustc.
227               Cargo's own JSON diagnostics and others coming from rustc are
228               still emitted. Cannot be used with human or short.
229
230   Manifest Options
231       --manifest-path path
232           Path to the Cargo.toml file. By default, Cargo searches for the
233           Cargo.toml file in the current directory or any parent directory.
234
235       --frozen, --locked
236           Either of these flags requires that the Cargo.lock file is
237           up-to-date. If the lock file is missing, or it needs to be updated,
238           Cargo will exit with an error. The --frozen flag also prevents
239           Cargo from attempting to access the network to determine if it is
240           out-of-date.
241
242           These may be used in environments where you want to assert that the
243           Cargo.lock file is up-to-date (such as a CI build) or want to avoid
244           network access.
245
246       --offline
247           Prevents Cargo from accessing the network for any reason. Without
248           this flag, Cargo will stop with an error if it needs to access the
249           network and the network is not available. With this flag, Cargo
250           will attempt to proceed without the network if possible.
251
252           Beware that this may result in different dependency resolution than
253           online mode. Cargo will restrict itself to crates that are
254           downloaded locally, even if there might be a newer version as
255           indicated in the local copy of the index. See the cargo-fetch(1)
256           command to download dependencies before going offline.
257
258           May also be specified with the net.offline config value
259           <https://doc.rust-lang.org/cargo/reference/config.html>.
260
261   Common Options
262       +toolchain
263           If Cargo has been installed with rustup, and the first argument to
264           cargo begins with +, it will be interpreted as a rustup toolchain
265           name (such as +stable or +nightly). See the rustup documentation
266           <https://rust-lang.github.io/rustup/overrides.html> for more
267           information about how toolchain overrides work.
268
269       -h, --help
270           Prints help information.
271
272       -Z flag
273           Unstable (nightly-only) flags to Cargo. Run cargo -Z help for
274           details.
275
276   Miscellaneous Options
277       -j N, --jobs N
278           Number of parallel jobs to run. May also be specified with the
279           build.jobs config value
280           <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults
281           to the number of CPUs.
282

PROFILES

284       Profiles may be used to configure compiler options such as optimization
285       levels and debug settings. See the reference
286       <https://doc.rust-lang.org/cargo/reference/profiles.html> for more
287       details.
288
289       Profile selection depends on the target and crate being built. By
290       default the dev or test profiles are used. If the --release flag is
291       given, then the release or bench profiles are used.
292
293
294       ┌────────────────────┬─────────────────┬───────────────────┐
295       │Target              │ Default Profile │ --release Profile │
296       ├────────────────────┼─────────────────┼───────────────────┤
297       │lib, bin, example   │ dev             release           
298       ├────────────────────┼─────────────────┼───────────────────┤
299       │test, bench, or any │ test            bench             
300       │target in "test" or │                 │                   │
301       │"bench" mode        │                 │                   │
302       └────────────────────┴─────────────────┴───────────────────┘
303
304       Dependencies use the dev/release profiles.
305

ENVIRONMENT

307       See the reference
308       <https://doc.rust-lang.org/cargo/reference/environment-variables.html>
309       for details on environment variables that Cargo reads.
310

EXIT STATUS

3120: Cargo succeeded.
313
314101: Cargo failed to complete.
315

EXAMPLES

317        1. Check the local package for errors:
318
319               cargo check
320
321        2. Check all targets, including unit tests:
322
323               cargo check --all-targets --profile=test
324

SEE ALSO

326       cargo(1), cargo-build(1)
327
328
329
330                                                                CARGO-CHECK(1)
Impressum