CARGO-FETCH(1)
๐ CARGO-FETCH(1) ๐
okay so bestie, you've stumbled into the General Commands Manual entry for cargo-fetch, and honestly? it's giving errand runner for your crate dependencies. let's get into it ๐
โจ NAME โจ
cargo-fetch โ fetch dependencies of a package from the network ๐ฆ
๐ธ SYNOPSIS ๐ธ
cargo fetch [options]
๐ DESCRIPTION ๐
so here's the tea: if you've got a Cargo.lock file hanging around, this command makes sure that every single one of your git dependencies and/or registry dependencies is downloaded and locally available. and the payoff? after a cargo fetch, all your subsequent Cargo commands can just run offline โ no cap โ unless the lock file changes. then it's back to the internet, sorry babe ๐ญ
if there's no lock file available? no problem. this command will generate the lock file first, and then go fetch the dependencies. main character behavior tbh ๐
and one more thing: if --target isn't specified, then all target dependencies get fetched. all of them. periodt.
๐ OPTIONS ๐
๐๏ธ Fetch options
--targettriple โ fetch for the target architecture you name. this flag can be specified multiple times (yes, really). the default is all architectures. the general format of the triple is<arch><sub>-<vendor>-<sys>-<abi>.
Possible values, bestie:
- Any supported target in
rustc --print target-list. "host-tuple", which will internally be substituted by the host's target. this one is particularly useful if you're cross-compiling some crates and you don't wanna specify your host's machine as a target โ for instance, anxtaskin a shared project that may be worked on by many hosts. shared-project girlies, this one's for you ๐ซถ- A path to a custom target specification. see Custom Target Lookup Path
<https://doc.rust-lang.org/rustc/targets/custom.html#custom-target-lookup-path>for more information.
this may also be specified with the build.target config value <https://doc.rust-lang.org/cargo/reference/config.html>.
heads up ๐ 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 <https://doc.rust-lang.org/cargo/reference/build-cache.html> documentation for more details.
๐ Display Options
-v,--verboseโ use verbose output. you can specify it 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>.-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.never: 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 will find it, bestie, it always does ๐--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. CI girlies rise up โจ
--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 ๐ญ 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.
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, iconic ๐
๐ 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.--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.
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>). nightlies only, bestie, sorry ๐ซ
-h,--helpโ prints help information. classic.-Zflag โ unstable (nightly-only) flags to Cargo. runcargo -Z helpfor details.
๐ฆ ENVIRONMENT ๐ฆ
see the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. env vars stay winning ๐
โญ EXIT STATUS โญ
0: Cargo succeeded. slay ๐101: Cargo failed to complete. it's giving tragedy ๐
๐ EXAMPLES ๐
- Fetch all dependencies:
cargo fetch
๐ SEE ALSO ๐
cargo(1), cargo-update(1), cargo-generate-lockfile(1)
and that's the whole page, bestie โ cargo-fetch(1) from the General Commands Manual, brought to you by the Cargo crew (no version or date on this one, it's mysterious like that ๐ ). go fetch your deps and hydrate. you got this ๐ซถโจ
๐ฆ where this page comes from
- centos-stream 10: cargo 1.99.1-1.el10 ยท (Apache-2.0 OR MIT) AND (Artistic-2.0 AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unicode-3.0)
- centos-stream 9: cargo 1.99.1-1.el9 ยท (Apache-2.0 OR MIT) AND (Artistic-2.0 AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unicode-3.0)
- fedora 43: cargo 1.99.0-1.fc43
- fedora 43: cargo 1.99.1-2.fc43 ยท (Apache-2.0 OR MIT) AND (Artistic-2.0 AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unicode-3.0)
- fedora 44: cargo 1.99.0-1.fc44
- fedora 44: cargo 1.99.1-2.fc44 ยท (Apache-2.0 OR MIT) AND (Artistic-2.0 AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0 AND Unicode-3.0)
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms