Skip to content
Latchkey

cargo vendor: Usage, Options & Common CI Errors

Vendor all dependencies into the repo for offline builds.

cargo vendor downloads every dependency source into a local folder (default vendor/) and prints the .cargo/config.toml snippet that redirects cargo to use it. Builds then need no registry access.

What it does

Copies the source of all locked dependencies into a directory and emits a [source] replacement config. Commit the directory (or restore it in CI) to build fully offline and reproducibly.

Common usage

Terminal
cargo vendor                          # writes ./vendor and prints config
cargo vendor third-party              # custom directory
cargo vendor > .cargo/config.toml     # capture the source replacement

Common CI error: vendor not configured

A vendored build still hits the network and fails because the printed [source.crates-io] replace-with config was never added to .cargo/config.toml. Fix: paste the snippet cargo vendor prints into .cargo/config.toml, then build with --offline. If the vendor dir drifts from Cargo.lock, re-run cargo vendor.

Options

FlagEffect
<path>Output directory (default vendor)
--versioned-dirsInclude version in dir names
--no-deleteKeep extra files in the dir

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →