# Upcoming changes to \`Cargo.lock\`

**URL:** <https://internals.rust-lang.org/t/upcoming-changes-to-cargo-lock/14017>\
**Category:** cargo\
**Created:** [February 9, 2021, 10:24pm UTC](https://internals.rust-lang.org/t/upcoming-changes-to-cargo-lock/14017 "2021-02-09T22:24:07Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alexcrichton](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/alexcrichton/32/4501_2.png) [@alexcrichton](https://internals.rust-lang.org/u/alexcrichton)\
**Post date:** [February 9, 2021, 10:24pm UTC](https://internals.rust-lang.org/t/upcoming-changes-to-cargo-lock/14017/1 "2021-02-09T22:24:07Z")

</div>

The Cargo team will [soon land a change](https://github.com/rust-lang/cargo/pull/9133) to the format of `Cargo.lock` files. This affects lock files checked into version control so we'd like to give a heads up to Cargo users that this is happening to make sure you're not surprised. Concretely the changes are:

- A `version = 3` marker will appear at the top of the file (a long overdue addition to lock files)
- Git dependencies using `branch = 'master'` in your manifest will be re-encoded as `?branch=master` in their URLs.

This lock file change is in preparation for fixing Cargo's implementation of git dependencies to depend on the default branch of a repository by default instead of unconditionally depending on the `master` branch of the repository. [Initial work for this change](https://github.com/rust-lang/cargo/pull/8522) landed way-back-when for Rust 1.47 released in October. With GitHub using a new default branch name more commonly this should help reduce boilerplate with using repositories that aren't using `master` as their default branch!

No breakage is expected from this change, so if something pops up please let us know! Also note that the change in Cargo has not landed as of the time of this writing but will likely land soon. This means you won't immediately see updates to your lock files after updating Cargo, but you'll see it in the next week or so.

---

<div class="post-metadata">

**Author:** ![bascule](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/bascule/32/3057_2.png) [@bascule](https://internals.rust-lang.org/u/bascule)\
**Post date:** [February 11, 2021, 4:51pm UTC](https://internals.rust-lang.org/t/upcoming-changes-to-cargo-lock/14017/2 "2021-02-11T16:51:02Z")

</div>

@alexcrichton is there an example of a `Cargo.lock` in the `version = 3` format somewhere handy? It'd be good to have test vectors for updating the `cargo-lock` crate: [Add support for V3 format · Issue #97 · RustSec/cargo-lock · GitHub](https://github.com/RustSec/cargo-lock/issues/97)

---

<div class="post-metadata">

**Author:** ![alexcrichton](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/alexcrichton/32/4501_2.png) [@alexcrichton](https://internals.rust-lang.org/u/alexcrichton)\
**Post date:** [February 11, 2021, 6:22pm UTC](https://internals.rust-lang.org/t/upcoming-changes-to-cargo-lock/14017/3 "2021-02-11T18:22:53Z")

</div>

There's an [example or two in the testsuite](https://github.com/rust-lang/cargo/blob/46bac2dc448ab12fe0f182bee8d35cc804d9a6af/tests/testsuite/lockfile_compat.rs#L26-L42) but for parsers the only real difference is the `version = 3` marker at the top.

---

<div class="post-metadata">

**Author:** ![steffahn](https://sea2.discourse-cdn.com/flex002/user_avatar/internals.rust-lang.org/steffahn/32/13288_2.png) [@steffahn](https://internals.rust-lang.org/u/steffahn)\
**Post date:** [December 22, 2024, 5:21pm UTC](https://internals.rust-lang.org/t/upcoming-changes-to-cargo-lock/14017/4 "2024-12-22T17:21:10Z")

</div>

This topic was automatically closed 540 days after the last reply. New replies are no longer allowed.
