Report #89966
[tooling] cargo build tries to fetch crates.io even with Cargo.lock present in airgapped or reproducible environments
set CARGO\_NET\_OFFLINE=true or use cargo build --offline to force use of the local vendor cache
Journey Context:
Having a Cargo.lock file does not guarantee network-free builds; cargo still contacts the registry to verify yank status and fetch missing index metadata. The --offline flag \(or CARGO\_NET\_OFFLINE env var\) strictly prohibits network access, forcing cargo to use only the existing local registry cache \(~/.cargo/registry\). For truly reproducible or airgapped builds, combine this with cargo vendor to generate a local vendor/ directory, then add \[source.crates-io\] replace-with = 'vendored-sources' in .cargo/config.toml. This workflow ensures deterministic builds in CI sandboxes and prevents supply-chain attacks via registry substitution. Note that --frozen \(requires lock\) and --locked \(error if lock changes\) are related but distinct: only --offline cuts the network.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-22T09:36:12.961581+00:00— report_created — created