CARGO-FETCH(1)
π¦ CARGO-FETCH(1) β the General Commands Manual glow-up
okay bestie, welcome to cargo-fetch β the command that goes and gets your deps off the internet so you can vibe offline later. it lives in the General Commands Manual, section 1, and it's giving "errand runner but make it essential" β¨
π NAME
cargo-fetch β fetch dependencies of a package from the network π
πΈ SYNOPSIS
cargo fetch [options]
π DESCRIPTION
so here's the tea π΅ β 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. and the slay part? subsequent Cargo commands will be able to run offline after a cargo fetch, unless the lock file changes. no cap.
if the lock file is not available, then this command will generate the lock file before fetching the dependencies. it's proactive like that π
if --target is not specified, then all target dependencies are fetched.
also!! see 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. iykyk π§
β¨ 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/guide/build-cache.html> for more details. don't say i didn't warn you π
π 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>. double it and it gets louder, iconic.-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, 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. periodt. π
--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. airplane mode main character energy βοΈ
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. not a bug, just the vibe.
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 bundle π«Ά--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. lowkey genius.
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-options flag to enable (see #14421 <https://github.com/rust-lang/cargo/issues/14421>). so if you're on stable, bestie, this one's not for you π
π 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. 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 wherecargolooks 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 skip that part π
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-options flag to enable (see #10098 <https://github.com/rust-lang/cargo/issues/10098>).
-h,--helpβ prints help information. the classic π«Ά-Zflag β unstable (nightly-only) flags to Cargo. runcargo -Z helpfor details. chaos mode, but make it documented π
π± ENVIRONMENT
see the reference <https://doc.rust-lang.org/cargo/reference/environment-variables.html> for details on environment variables that Cargo reads. yes, it reads your env, it's nosy like that π
β EXIT STATUS
0: Cargo succeeded. π101: Cargo failed to complete. π
π EXAMPLES
- Fetch all dependencies:
cargo fetch
π SEE ALSO
cargo(1), cargo-update(1), cargo-generate-lockfile(1)
and that's the whole page, bestie π this was CARGO-FETCH(1) from the General Commands Manual, and the footer is literally just the same name again (CARGO-FETCH(1)) because manpages love a symmetry moment. go fetch your deps, you absolute icon πβ¨
π¦ where this page comes from
- ubuntu jammy: cargo-1.82 1.82.0+dfsg0ubuntu0~jammy-0ubuntu0.22.04.1 Β· Apache-2.0 WITH LLVM exception
- ubuntu noble: cargo-1.82 1.82.0+dfsg0ubuntu0-0ubuntu0.24.04.1 Β· 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