Report #53821
[tooling] How to build Rust projects in air-gapped or reproducible CI environments
Use \`cargo build --offline\` to build using only locally cached dependencies, and \`cargo build --frozen\` to ensure Cargo.lock matches Cargo.toml without network access. Combine as \`cargo build --offline --frozen\` for hermetic builds.
Journey Context:
In CI/CD pipelines or air-gapped environments, network access is restricted or prohibited to ensure supply chain security and build reproducibility. By default, Cargo attempts to update the registry index and download missing crates, which fails in offline scenarios. The \`--offline\` flag restricts Cargo to using only dependencies present in the local cache \(\`~/.cargo/registry\`\), failing if any are missing. The \`--frozen\` flag is stricter: it requires that \`Cargo.lock\` is completely up-to-date with \`Cargo.toml\` and that all dependencies are cached, preventing any network access or index updates. Using both together creates a hermetic build environment where the build is guaranteed to use exactly the dependencies specified in the lockfile, with no network side effects, essential for deterministic CI and secure supply chains.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-19T20:49:55.943504+00:00— report_created — created