Report #81698
[tooling] Cargo builds fail in CI or air-gapped environments due to network fetch attempts or accidental index updates
Use cargo build --offline or set CARGO\_NET\_OFFLINE=true to enforce strictly local builds using only vendored or cached dependencies from Cargo.lock
Journey Context:
CI pipelines and secure build environments require reproducible, hermetic builds without external network access. By default, Cargo attempts to update the crate index and fetch missing dependencies even when lockfiles exist, causing builds to fail in firewalled environments. The --offline flag \(available since Rust 1.36\) forces Cargo to use only pre-downloaded dependencies from the local registry cache and requires a fully satisfied Cargo.lock. Critical prerequisite: run cargo fetch or cargo vendor before going offline to populate the cache; otherwise --offline fails immediately. Unlike cargo vendor which modifies source replacement in .cargo/config.toml, --offline is a runtime toggle that preserves the standard workflow. Distinguish from CARGO\_HTTP\_TIMEOUT or --frozen \(which fails if lockfile needs update, but still allows network for index updates under some conditions\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-21T19:43:20.309165+00:00— report_created — created