CARGO-CHECK(1)
๐ NAME ๐
hiii bestie ๐ซถ welcome to the cargo-check manual page โ section 1, General Commands Manual, and honestly? she's that girl. no cap.
cargo-check โ Check the current package โจ
๐ฆ SYNOPSIS ๐ฆ
cargo check [options]
like. that's it. that's the whole vibe. ๐
๐ธ DESCRIPTION ๐ธ
okay so cargo check goes through your local package and every single one of its dependencies and checks them all for errors. that's the job. ๐ซก
here's the tea though: it basically compiles the packages without doing the final step of code generation, which is why it's faster than running cargo build. she's giving speed, she's giving efficiency, we love her for it.
the compiler will save metadata files to disk so that future runs can reuse them โ as long as the source hasn't been modified. free caching, we ate. ๐ฅ
โ ๏ธ but bestie, listen: some diagnostics and errors are only emitted during code generation, so they inherently won't be reported with cargo check. not a bug, just the rules of the game. ๐ญ
๐ OPTIONS ๐
๐ฆ Package Selection ๐ฆ
by default, when no package selection options are given, the packages selected depend on the selected manifest file (based on the current working directory if --manifest-path is not given). if the manifest is the root of a workspace then the workspace's default members are selected, otherwise only the package defined by the manifest gets selected. iykyk.
the default members of a workspace can be set explicitly with the workspace.default-members key in the root manifest. if that's not set, then:
- a virtual workspace will include all workspace members (equivalent to passing
--workspace) - a non-virtual workspace will include only the root crate itself
-p*spec*โฆ,--package*spec*โฆ โ Check only the specified packages. Seecargo-pkgid(1)for the SPEC format. This flag may be specified multiple times and supports common Unix glob patterns like*,?and[]. However, to avoid your shell accidentally expanding glob patterns before Cargo handles them, you must use single quotes or double quotes around each pattern. yes, the quotes matter, don't fight it. ๐--workspaceโ Check all members in the workspace. all of them. every single one. ๐--allโ Deprecated alias for--workspace. (she's retired, pls use the new one ๐)--exclude*SPEC*โฆ โ Exclude the specified packages. Must be used in conjunction with the--workspaceflag. This flag may be specified multiple times and supports common Unix glob patterns like*,?and[]. However, to avoid your shell accidentally expanding glob patterns before Cargo handles them, you must use single quotes or double quotes around each pattern.
๐ฏ Target Selection ๐ฏ
when no target selection options are given, cargo check will check all binary and library targets of the selected packages. binaries get skipped if they have required-features that are missing. bye bestie. ๐
passing target selection flags will check only the specified targets.
๐ข note that--bin,--example,--testand--benchflags also support common Unix glob patterns like*,?and[]. However, to avoid your shell accidentally expanding glob patterns before Cargo handles them, you must use single quotes or double quotes around each glob pattern.
--libโ Check the package's library.--bin*name*โฆ โ Check the specified binary. This flag may be specified multiple times and supports common Unix glob patterns.--binsโ Check all binary targets.--example*name*โฆ โ Check the specified example. This flag may be specified multiple times and supports common Unix glob patterns.--examplesโ Check all example targets.--test*name*โฆ โ Check the specified integration test. This flag may be specified multiple times and supports common Unix glob patterns.--testsโ Check all targets in test mode that have thetest = truemanifest flag set. By default this includes the library and binaries built as unittests, and integration tests. Be aware that this will also build any required dependencies, so the lib target may be built twice (once as a unittest, and once as a dependency for binaries, integration tests, etc.). Targets may be enabled or disabled by setting thetestflag in the manifest settings for the target.--bench*name*โฆ โ Check the specified benchmark. This flag may be specified multiple times and supports common Unix glob patterns.--benchesโ Check all targets in benchmark mode that have thebench = truemanifest flag set. By default this includes the library and binaries built as benchmarks, and bench targets. Be aware that this will also build any required dependencies, so the lib target may be built twice (once as a benchmark, and once as a dependency for binaries, benchmarks, etc.). Targets may be enabled or disabled by setting thebenchflag in the manifest settings for the target.--all-targetsโ Check all targets. This is equivalent to specifying--lib --bins --tests --benches --examples. one flag, all the targets, main character energy fr fr. โจ
๐ Feature Selection ๐
the feature flags let you control which features are enabled. when no feature options are given, the default feature is activated for every selected package.
see the features documentation at https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options for more details. ๐
-Ffeatures,--featuresfeatures โ Space or comma separated list of features to activate. Features of workspace members may be enabled withpackage-name/feature-namesyntax. This flag may be specified multiple times, which enables all specified features.--all-featuresโ Activate all available features of all selected packages. go big or go home. ๐ฅ--no-default-featuresโ Do not activate the default feature of the selected packages.
๐ฅ Compilation Options ๐ฅ
--targettriple โ Check for the given architecture. The default is the host architecture. The general format of the triple is<arch><sub>-<vendor>-<sys>-<abi>. Runrustc --print target-listfor a list of supported targets. This flag may be specified multiple times.
This may also be specified with the build.target config value at https://doc.rust-lang.org/cargo/reference/config.html.
๐ก note that specifying this flag makes Cargo run in a different mode where the target artifacts are placed in a separate directory. See the build cache documentation at https://doc.rust-lang.org/cargo/guide/build-cache.html for more details.
-r,--releaseโ Check optimized artifacts with thereleaseprofile. See also the--profileoption for choosing a specific profile by name.--profilename โ Check with the given profile.
as a special case, specifying the test profile will also enable checking in test mode, which will enable checking tests and enable the test cfg option. See rustc tests at https://doc.rust-lang.org/rustc/tests/index.html for more detail.
see the reference at https://doc.rust-lang.org/cargo/reference/profiles.html for more details on profiles.
--timings=fmtsโ Output information how long each compilation takes, and track concurrency information over time. Accepts an optional comma-separated list of output formats;--timingswithout an argument will default to--timings=html. Specifying an output format (rather than the default) is unstable and requires-Zunstable-options. Valid output formats:html(unstable, requires-Zunstable-options): Write a human-readable filecargo-timing.htmlto thetarget/cargo-timingsdirectory with a report of the compilation. Also write a report to the same directory with a timestamp in the filename if you want to look at older runs. HTML output is suitable for human consumption only, and does not provide machine-readable timing data.json(unstable, requires-Zunstable-options): Emit machine-readable JSON information about timing information.
๐ Output Options ๐
--target-dirdirectory โ Directory for all generated artifacts and intermediate files. May also be specified with theCARGO_TARGET_DIRenvironment variable, or thebuild.target-dirconfig value athttps://doc.rust-lang.org/cargo/reference/config.html. Defaults totargetin the root of the workspace.
๐ฅ๏ธ Display Options ๐ฅ๏ธ
-v,--verboseโ 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 theterm.verboseconfig value athttps://doc.rust-lang.org/cargo/reference/config.html. double-v? that's the deep lore, bestie. ๐-q,--quietโ Do not print cargo log messages. May also be specified with theterm.quietconfig value athttps://doc.rust-lang.org/cargo/reference/config.html.--colorwhen โ Control when colored output is used. Valid values:auto(default): Automatically detect if color support is available on the terminal.always: Always display colors.never: Never display colors.
May also be specified with the term.color config value at https://doc.rust-lang.org/cargo/reference/config.html. (we're an always household personally but ok ๐)
--message-formatfmt โ The output format for diagnostic messages. Can be specified multiple times and consists of comma-separated values. Valid values:human(default): Display in a human-readable text format. Conflicts withshortandjson.short: Emit shorter, human-readable text messages. Conflicts withhumanandjson.json: Emit JSON messages to stdout. See the reference athttps://doc.rust-lang.org/cargo/reference/external-tools.html#json-messagesfor more details. Conflicts withhumanandshort.json-diagnostic-short: Ensure therenderedfield of JSON messages contains the "short" rendering fromrustc. Cannot be used withhumanorshort.json-diagnostic-rendered-ansi: Ensure therenderedfield of JSON messages contains embedded ANSI color codes for respectingrustc's default color scheme. Cannot be used withhumanorshort.json-render-diagnostics: Instruct Cargo to not includerustcdiagnostics in JSON messages printed, but instead Cargo itself should render the JSON diagnostics coming fromrustc. Cargo's own JSON diagnostics and others coming fromrustcare still emitted. Cannot be used withhumanorshort.
๐ Manifest Options ๐
--manifest-pathpath โ Path to theCargo.tomlfile. By default, Cargo searches for theCargo.tomlfile in the current directory or any parent directory. it will hunt it down fr. ๐--ignore-rust-versionโ Ignorerust-versionspecification in packages.--lockedโ Asserts that the exact same dependencies and versions are used as when the existingCargo.lockfile was originally generated. Cargo will exit with an error when either of the following scenarios arises:- The lock file is missing.
- Cargo attempted to change the lock file due to a different dependency resolution.
๐จ she said what she said: --locked does not play. lock file missing or drifting = error, periodt.
And honestly? That's the whole point โ it may be used in environments where deterministic builds are desired, such as in CI pipelines. chef's kiss for reproducible vibes. ๐
--offlineโ literally tells Cargo do not touch the network, for any reason. No cap.- 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.
- > Beware bestie, 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
cargo-fetch(1)to download dependencies before going offline. ๐ญ - May also be specified with the
net.offlineconfig value (https://doc.rust-lang.org/cargo/reference/config.html).
--frozenโ the two-for-one combo, it's giving bundle deal ๐ . Equivalent to specifying both--lockedand--offline.
โจ Common Options โจ
+toolchainโ if Cargo has been installed with rustup, and the first argument tocargobegins with+, it will be interpreted as a rustup toolchain name (such as+stableor+nightly). See the rustup documentation (https://rust-lang.github.io/rustup/overrides.html) for more information about how toolchain overrides work.--config KEY=VALUEorPATHโ overrides a Cargo configuration value. The argument should be in TOML syntax ofKEY=VALUE, or provided as a path to an extra configuration file. This flag may be specified multiple times (yes, stack 'em ๐ซถ). See the command-line overrides section (https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides) for more information.-C PATHโ changes the current working directory before executing any specified operations. This affects things like where cargo looks by default for the project manifest (Cargo.toml), as well as the directories searched for discovering.cargo/config.toml, for example. This option must appear before the command name, for examplecargo -C path/to/my-project build.- > ๐จ This option is only available on the nightly channel (
https://doc.rust-lang.org/book/appendix-07-nightly-rust.html) and requires the-Z unstable-optionsflag to enable (see #10098 โhttps://github.com/rust-lang/cargo/issues/10098). So likeโฆ nightly besties only, iykyk.
- > ๐จ This option is only available on the nightly channel (
-h,--helpโ prints help information. our fave, the little rescue button ๐-Z flagโ unstable (nightly-only) flags to Cargo. Runcargo -Z helpfor details. spicy ๐ถ๏ธ territory fr fr.
๐ Miscellaneous Options ๐
-j N,--jobs Nโ number of parallel jobs to run. May also be specified with thebuild.jobsconfig value (https://doc.rust-lang.org/cargo/reference/config.html). Defaults to the number of logical CPUs. If negative, it sets the maximum number of parallel jobs to the number of logical CPUs plus provided value. If a stringdefaultis provided, it sets the value back to defaults. Should not be0. ๐--keep-goingโ build as many crates in the dependency graph as possible, rather than aborting the build on the first one that fails to build. main character energy: it does not stop for anybody ๐
For example if the current package depends on dependencies fails and works, one of which fails to build, cargo check -j1 may or may not build the one that succeeds (depending on which one of the two builds Cargo picked to run first), whereas cargo check -j1 --keep-going would definitely run both builds, even if the one run first fails.
--future-incompat-reportโ displays a future-incompat report for any future-incompatible warnings produced during execution of this command. a lil peek into the future ๐ฎ- See
cargo-report(1)
- See
๐ธ ENVIRONMENT ๐ธ
See the reference (https://doc.rust-lang.org/cargo/reference/environment-variables.html) for details on environment variables that Cargo reads. ๐ฆ
๐ EXIT STATUS ๐
0: Cargo succeeded. slay โจ101: Cargo failed to complete. ๐
โจ EXAMPLES โจ
- Check the local package for errors:
cargo check
- Check all targets, including unit tests:
cargo check --all-targets --profile=test
๐ฆ SEE ALSO ๐ฆ
and that's the whole page bestie, we ate and left no crumbs ๐ this was CARGO-CHECK(1) โ straight outta the Cargo manual, source and version and date all living down there in the footer, so go check your local copy if you want the exact receipt ๐๐
๐ฆ where this page comes from
- ubuntu jammy: cargo-1.80 1.80.1+dfsg0ubuntu1~bpo0-0ubuntu0.22.04.1 ยท Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.80 1.80.1+dfsg0ubuntu1-0ubuntu0.24.04.01 ยท MIT OR Apache-2.0
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms