What Is Cargo.lock?
Cargo.lock explained, including what it does and how it matters in CI/CD.
Cargo.lock records the exact versions of every dependency resolved for a Rust project.
What it is
It guarantees reproducible builds. The convention: commit Cargo.lock for binaries/applications; for libraries it is optional.
Why it matters in CI/CD
CI uses cargo build --locked so a stale Cargo.lock fails the build instead of silently resolving new versions.
Key takeaways
- Cargo.lock pins exact crate versions.
- Commit it for applications.
- Use --locked in CI.
Related guides
What Is Cargo.toml?Cargo.toml is the manifest for a Rust crate. Learn what it declares for CI builds.
What Is a Lockfile and Why Should You Commit It?A lockfile pins the exact versions of every dependency so builds are reproducible. Learn why committing it is…
What Is a Reproducible Build?A reproducible build produces byte-for-byte identical output from the same source, every time. Learn what bre…