CARGO-CHECK(1)
CARGO-CHECK(1) ๐
okay so bestie, welcome to the cargo-check manual page โ General Commands Manual energy, but make it cute. let's get into it ๐ซถ
โจ NAME โจ
cargo-check โ Check the current package ๐
โจ SYNOPSIS โจ
cargo check [options]
โจ DESCRIPTION โจ
So what this does is: it checks a local package and all of its dependencies for errors. The way it works is it basically compiles the packages but โ stops right before the final step of code generation, which is why it's faster than running cargo build. Lowkey iconic for when you just want to know if things are broken without the full build vibe.
The compiler will save metadata files to disk so that future runs can reuse them if the source hasn't been modified. Reuse queen ๐
โ ๏ธ but heads up bestie: some diagnostics and errors are only emitted during code generation, so they inherently won't be reported with cargo check. Not everything shows up here, no cap. ๐
โจ 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 will be selected.
The default members of a workspace can be set explicitly with the workspace.default-members key in the root manifest. If this is not set, a virtual workspace will include all workspace members (equivalent to passing --workspace), and a non-virtual workspace will include only the root crate itself. the way it just decides for you... main character energy fr โจ
-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. protect the globs, bestie ๐ฅบ--workspaceโ Check all members in the workspace. the whole squad ๐ซถ--allโ Deprecated alias for--workspace. it's giving legacy, we don't really use it anymore ๐--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. not like other girls (packages) ๐
๐ฏ Target Selection ๐ฏ
When no target selection options are given, cargo check will check all binary and library targets of the selected packages. Binaries are skipped if they have required-features that are missing. bye to the ones that don't qualify โ๏ธ
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. quote ur globs or the shell will do crimes ๐ญ
--libโ Check the package's library. the library, the moment, the icon ๐--bin nameโฆโ Check the specified binary. This flag may be specified multiple times and supports common Unix glob patterns.--binsโ Check all binary targets. all of them, no crumbs ๐--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 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. double-building the lib? it's doing the most, but respectfully ๐--bench nameโฆโ Check the specified benchmark. This flag may be specified multiple times and supports common Unix glob patterns.--benchesโ Check all targets 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. same double-build situation, she's committed ๐ฅ--all-targetsโ Check all targets. This is equivalent to specifying--lib --bins --tests --benches --examples. literally everything, all at once, obsessed ๐
๐ท Feature Selection ๐ท
The feature flags allow you to control which features are enabled. When no feature options are given, the default feature is activated for every selected package. defaults stay winning, periodt ๐
See the features documentation for more details: https://doc.rust-lang.org/cargo/reference/features.html#command-line-feature-options
-F features,--features featuresโ 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. stack them like bracelets โจ--all-featuresโ Activate all available features of all selected packages. full send ๐ฅ--no-default-featuresโ Do not activate the default feature of the selected packages. we're going off-script ๐
๐ ๏ธ Compilation Options ๐ ๏ธ
--target tripleโ Check for the specified target architecture. Flag may be specified multiple times. The default is the host architecture. The general format of the triple is<arch><sub>-<vendor>-<sys>-<abi>.
Possible values:
- Any supported target in
rustc --print target-list. "host-tuple", which will internally be substituted by the host's target. This can be particularly useful if you're cross-compiling some crates, and don't want to specify your host's machine as a target (for instance, anxtaskin a shared project that may be worked on by many hosts). very "i contain multitudes" of it ๐ฆ- A path to a custom target specification. See Custom Target Lookup Path for more information:
https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path
This may also be specified with the build.target config value: 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 for more details: https://doc.rust-lang.org/cargo/reference/build-cache.html
-r,--releaseโ Check optimized artifacts with thereleaseprofile. See also the--profileoption for choosing a specific profile by name. optimized and unbothered ๐--profile nameโ 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 for more detail: https://doc.rust-lang.org/rustc/tests/index.html
See the reference for more details on profiles: https://doc.rust-lang.org/cargo/reference/profiles.html
--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. cute to look at, not for the robots ๐json(unstable, requires-Zunstable-options): Emit machine-readable JSON information about timing information. for the robots ๐ค
๐ Output Options ๐
--target-dir directoryโ Directory for all generated artifacts and intermediate files. May also be specified with theCARGO_TARGET_DIRenvironment variable, or thebuild.target-dirconfig value:https://doc.rust-lang.org/cargo/reference/config.html. Defaults totargetin the root of the workspace. home sweet target ๐
๐ฌ 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:https://doc.rust-lang.org/cargo/reference/config.html. twice?? very verbose, very demure ๐-q,--quietโ Do not print cargo log messages. May also be specified with theterm.quietconfig value:https://doc.rust-lang.org/cargo/reference/config.html. shhh ๐คซ--color whenโ 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: https://doc.rust-lang.org/cargo/reference/config.html
--message-format fmtโ 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 for more details:https://doc.rust-lang.org/cargo/reference/external-tools.html#json-messages. Conflicts withhumanandshort.json-diagnostic-short: Ensure therenderedfield of JSON messages contains the "short" rendering from rustc. Cannot be used withhumanorshort.json-diagnostic-rendered-ansi: Ensure therenderedfield of JSON messages contains embedded ANSI color codes for respecting rustc's default color scheme. Cannot be used withhumanorshort.json-render-diagnostics: Instruct Cargo to not include rustc diagnostics in JSON messages printed, but instead Cargo itself should render the JSON diagnostics coming from rustc. Cargo's own JSON diagnostics and others coming from rustc are still emitted. Cannot be used withhumanorshort.
part 1 done bestie, there's more coming so don't go anywhere ๐
Manifest Options ๐โจ
--manifest-pathpath โ tells Cargo exactly where yourCargo.tomllives. No flag? Then Cargo goes hunting for theCargo.tomlfile in the current directory, or literally any parent directory above it. ๐ต๏ธโโ๏ธ--ignore-rust-versionโ pretends therust-versionspec in your packages simply does not exist. It's giving "I don't see it so it can't hurt me" ๐--lockedโ pinky-promises that the exact same dependencies and versions get used as when the existingCargo.lockfile was originally generated. Cargo will bail with an error when either of these happens:- The lock file is missing.
- Cargo tried to change the lock file because dependency resolution came out different.
Perfect for environments that want deterministic builds, like CI pipelines. Queen of consistency ๐
--offlineโ Cargo is not allowed to touch the network for any reason. Without this flag, if Cargo needs the network and there's no network, it just stops with an error. With this flag, it'll try to keep going without the network if it possibly can. โ๏ธ
Beware bestie: this can give you different dependency resolution than online mode. Cargo limits itself to crates already downloaded locally, even if a newer version exists according to the local copy of the index. And if you wanna go offline properly, hit up cargo-fetch(1) to download your dependencies first. ๐
You can also set this with the net.offline config value <https://doc.rust-lang.org/cargo/reference/config.html>.
--frozenโ the two-for-one special: exactly the same as passing both--lockedand--offline. ๐ง--lockfile-pathPATH โ moves the lockfile from its default spot (<workspace_root>/Cargo.lock) over to PATH. And PATH must end withCargo.lock(like--lockfile-path /tmp/temporary-lockfile/Cargo.lock). Heads up: giving--lockfile-pathmakes Cargo ignore any existing lockfile at the default path, and instead it'll either use the lockfile at PATH, or write a brand new lockfile into the PATH you provided if nothing's there. This flag is the moment for running most commands inside read-only directories, writing the lockfile into the PATH you gave. ๐
This option is only available on the nightly channel <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html> and it needs the -Z unstable-options flag turned on to enable it (see #14421 <https://github.com/rust-lang/cargo/issues/14421>).
Common Options ๐ซถ
+toolchainโ if Cargo got installed with rustup, and the very first argument tocargostarts with+, it gets read as a rustup toolchain name (think+stableor+nightly). Peep the rustup docs <https://rust-lang.github.io/rustup/overrides.html> for the whole tea on how toolchain overrides work. โ--configKEY=VALUE or PATH โ overrides a Cargo configuration value. The argument is either TOML syntax inKEY=VALUEform, or a path to an extra config file. You can stack this flag as many times as you want. See the command-line overrides section <https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides> for more. ๐-CPATH โ changes the current working directory before running any of the operations you asked for. This affects stuff like where cargo looks by default for the project manifest (Cargo.toml), and which directories get searched when discovering.cargo/config.toml, for example. This option must come before the command name, likecargo -C path/to/my-project build. ๐
Also nightly-only <https://doc.rust-lang.org/book/appendix-07-nightly-rust.html>, and it needs -Z unstable-options enabled (see #10098 <https://github.com/rust-lang/cargo/issues/10098>).
-h,--helpโ prints help information. Classic, beloved, never misses. ๐-Zflag โ the unstable (nightly-only) flags for Cargo. Runcargo -Z helpfor the details. ๐งช
Miscellaneous Options ๐
-jN,--jobsN โ how many parallel jobs to run. You can also set this with thebuild.jobsconfig value <https://doc.rust-lang.org/cargo/reference/config.html>. Defaults to the number of logical CPUs. If it's negative, it sets the maximum number of parallel jobs to the number of logical CPUs plus the value you gave. If a stringdefaultis provided, it sets the value back to defaults. And it should not be0. ๐ซ--keep-goingโ builds as many crates in the dependency graph as it possibly can, instead of aborting the whole build the second one of them fails. ๐ช
For example, if the current package depends on dependencies that fail and work, one of which fails to build, cargo check -j1 may or may not build the one that succeeds (depends on which of the two builds Cargo picked to run first), whereas cargo check -j1 --keep-going would definitely run both builds, even if the one that ran first fails.
--future-incompat-reportโ displays a future-incompat report for any future-incompatible warnings that got produced while this command was executing. ๐ฎ
See cargo-report(1).
๐ ENVIRONMENT ๐
See the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for the deets 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, no cap โ this was the CARGO-CHECK(1) manual page from the Cargo docs (that's the source and version line doing its little footer moment at the bottom of the original ๐), dated with its own little timestamp, and you read every single word of it. Obsessed with you fr fr ๐
๐ฆ๐
๐ฆ where this page comes from
- ubuntu resolute: cargo-1.93 1.93.1+dfsg-0ubuntu6 ยท 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