rules_rust icon indicating copy to clipboard operation
rules_rust copied to clipboard

Don't update Cargo.lock when re-pinning

Open cameron-martin opened this issue 3 years ago • 6 comments

When doing something that requires updating cargo-bazel-lock.json, for example changing the rust version or even the initial setup of bazel, the only option is to do a full cargo update, which updates a lot of versions in the Cargo.lock. However, it would be nice if there was a way of generating the cargo-bazel-lock.json only, using the versions of the packages defined in the Cargo.lock.

Is there any technical reason that it is required to tie together the updating of cargo-bazel-lock.json and Cargo.lock?

This is similar to https://github.com/bazelbuild/rules_rust/issues/1231.

cameron-martin avatar Aug 18 '22 11:08 cameron-martin

See https://bazelbuild.github.io/rules_rust/crate_universe.html#repinning--updating-dependencies

You can currently use CARGO_BAZEL_REPIN=workspace to generate the file without updating any dependencies - does this work for you?

illicitonion avatar Aug 18 '22 11:08 illicitonion

Thanks for the info, this does indeed work. This is not the most intuitive naming, unless you know the behaviour of cargo update --workspace.

cameron-martin avatar Aug 18 '22 12:08 cameron-martin

Yeah, I agree... @UebelAndre how would you feel about a breaking change where we make CARGO_BAZEL_REPIN no longer take a truthy value, and instead require either setting CARGO_BAZEL_REPIN=update-all or CARGO_BAZEL_REPIN=regenerate-lockfile?

illicitonion avatar Aug 18 '22 13:08 illicitonion

I'll re-open this if there is a potential change here.

cameron-martin avatar Aug 18 '22 13:08 cameron-martin

Yeah, I agree... @UebelAndre how would you feel about a breaking change where we make CARGO_BAZEL_REPIN no longer take a truthy value, and instead require either setting CARGO_BAZEL_REPIN=update-all or CARGO_BAZEL_REPIN=regenerate-lockfile?

I'm totally fine with any kind of aliasing folks want to add to represent some flag combination but I'd still like there to be some default behavior for a truthy value. What the truthy value evaluates to I'm also fairly flexible on. It should be the most common of the values users would otherwise set to CARGO_BAZEL_REPIN but I don't want to be the one to choose since I'm already familiar with how it currently works and a change would take some getting used to.

UebelAndre avatar Sep 05 '22 21:09 UebelAndre

My vote would be for making workspace/generate-lockfile the default, as I think that's the least surprising: https://github.com/bazelbuild/rules_rust/issues/1535#issuecomment-1236650916

dae avatar Sep 06 '22 03:09 dae

My vote would be for making workspace/generate-lockfile the default, as I think that's the least surprising: #1535 (comment)

Pull requests would be welcome 😄

UebelAndre avatar Oct 15 '22 15:10 UebelAndre