CARGO-FETCH(1)
๐ CARGO-FETCH ๐
okay so bestie, welcome to CARGO-FETCH(1) โ yes that's section 1 of the General Commands Manual, we're in the big-girl section now ๐
. This is the page for cargo fetch, and by the end of it you're gonna be fetching deps like it's nothing. no cap. ๐ซถ
โจ NAME โจ
cargo-fetch โ fetch dependencies of a package from the network ๐๐
๐ธ SYNOPSIS ๐ธ
cargo fetch [options]
๐ฆ DESCRIPTION ๐ฆ
so here's the tea, bestie ๐:
If a Cargo.lock file is available, this command will make sure that all of the git dependencies and/or registry dependencies are downloaded and locally available. The way that subsequent Cargo commands will be able to run offline after a cargo fetch unless the lock file changes? iconic. โจ
If the lock file is not available, then this command will generate the lock file before fetching the dependencies. it's giving prepared. ๐
If --target is not specified, then all target dependencies are fetched. all of them. the whole squad. ๐
See also the cargo-prefetch plugin (https://crates.io/crates/cargo-prefetch) which adds a command to download popular crates. This may be useful if you plan to use Cargo without a network with the --offline flag. lowkey a lifesaver for offline vibes ๐
๐ OPTIONS ๐
Fetch options
--targettriple โ fetch for the given architecture. The default is all architectures. 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 (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 (https://doc.rust-lang.org/cargo/reference/build-cache.html) for more details. not me moving your artifacts to a whole new address ๐ ๐
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). tell me everything, I wanna know everything ๐ฃ๏ธโจ-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 ๐คซ--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. ๐ periodtnever: never display colors. ๐ซ
May also be specified with the term.color config value (https://doc.rust-lang.org/cargo/reference/config.html).
Manifest Options
--manifest-pathpath โ path to theCargo.tomlfile. By default, Cargo searches for theCargo.tomlfile in the current directory or any parent directory. it'll go looking for it, don't worry ๐ต๏ธโโ๏ธ--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. ๐
It may be used in environments where deterministic builds are desired, such as in CI pipelines. deterministic queen behavior fr fr ๐
--offlineโ prevents Cargo from accessing the network for any reason. 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 that 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. so like, she's working with what she's got ๐
May also be specified with the net.offline config value (https://doc.rust-lang.org/cargo/reference/config.html).
--frozenโ equivalent to specifying both--lockedand--offline. two-for-one deal, we love a combo ๐--lockfile-pathPATH โ changes the path of the lockfile from the default (<workspace_root>/Cargo.lock) to PATH. PATH must end withCargo.lock(e.g.--lockfile-path /tmp/temporary-lockfile/Cargo.lock). Note that providing--lockfile-pathwill ignore existing lockfile at the default path, and instead will either use the lockfile from PATH, or write a new lockfile into the provided PATH if it doesnโt exist. This flag can be used to run most commands in read-only directories, writing lockfile into the provided PATH. ๐๏ธโจ
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 #14421,https://github.com/rust-lang/cargo/issues/14421). nightly girlies only ๐
Common Options
+toolchain โ if Cargo has been installed with rustup, and the first argument to cargo begins 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. pick your fighter โ๏ธ--configKEY=VALUE or PATH โ 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. See the command-line overrides section (https://doc.rust-lang.org/cargo/reference/config.html#command-line-overrides) for more information. โ๏ธ-CPATH โ 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. order matters bestie, don't fight it ๐ซถ
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). โจ
-h,--helpโ prints help information. when in doubt, ask for help, that's the vibe ๐โโ๏ธ-Zflag โ unstable (nightly-only) flags to Cargo. Runcargo -Z helpfor details. the secret menu ๐ฎ
๐ ENVIRONMENT ๐
See the reference (https://doc.rust-lang.org/cargo/reference/environment-variables.html) for details on environment variables that Cargo reads. Cargo's out here reading env vars like they're the group chat ๐ฑ๐
โญ EXIT STATUS โญ
0: Cargo succeeded. ๐ slay101: Cargo failed to complete. ๐ญ rip
๐ง EXAMPLES ๐ง
- Fetch all dependencies:
cargo fetch
that's it. that's the whole thing. go get your deps bestie ๐
๐ฅ SEE ALSO ๐ฅ
cargo(1), cargo-update(1), cargo-generate-lockfile(1) โ the rest of the girlies, go say hi ๐
and that's the whole page!! this footer's just CARGO-FETCH(1) again โ same name, General Commands Manual, section 1 โ no version stamp or date on it, she's simply timeless like that ๐
โจ mwah, go fetch something ๐ซถ
๐ฆ where this page comes from
- ubuntu jammy: cargo-1.89 1.89.0+dfsg~24.04-0ubuntu0.22.04.2 ยท Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.89 1.89.0+dfsg~24.04-0ubuntu0.24.04.2 ยท Apache-2.0 WITH LLVM exception
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms