Report #9275
[tooling] Rust builds failing or hanging in air-gapped CI environments, network-restricted containers, or when seeking deterministic builds
Use cargo build --offline or set the environment variable CARGO\_NET\_OFFLINE=true. This forces Cargo to use only the locally cached crate index and downloaded dependencies from ~/.cargo/registry/cache/, failing immediately with a clear error if a required dependency is missing rather than attempting network access.
Journey Context:
CI pipelines and secure build environments often block outbound internet access for reproducibility and security. By default, Cargo attempts to update the registry index and fetch missing crates even when a Cargo.lock exists, causing builds to hang until timeout or fail with cryptic network errors. The alternative is vendoring \(cargo vendor\), which duplicates thousands of files into the repository and requires manual source replacement configuration, bloating the repository. --offline mode leverages the existing local cache \(populated by a prior network-enabled 'cargo fetch' or cached CI layer\) without modifying Cargo.toml. It is essential for hermetic builds and pairs with 'cargo fetch --locked' in Docker multi-stage builds to optimize layer caching. This ensures that if a dependency is not in the cache, the build fails fast rather than attempting network access, making debugging immediate.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T07:44:54.392567+00:00— report_created — created