I'm in a bit of a pickle: right now, my CI will bump the version number of my
--bin package in Cargo.toml after all checks/tests, and commit/push that change. However, if a later job in the pipeline) then attempts to
cargo publish this new version, it will fail. This seems to happen because the root version in the lockfile is out-of-date:
publish updates Cargo.lock as a first step, but then immediately fails because the repo is not current.
My workaround here is to run a simple command (like
cargo fetch) which will update the lockfile as a side effect before committing the version change. However, it seems to me that there should be a low-level cargo command which does only that, so I created one. I've created a simple demo PR (edit: here) for rust-lang/cargo that adds a
sync-lockfile command. This command differs from
generate-lockfile in that if a lockfile already exists, it updates only the root version to match what's in Cargo.toml.
Is there anyone who's experienced this problem? Is there already a solution for me out there? Looking for feedback before making a real RFC; I'm willing to implement--the actual work seems pretty trivial, and my demo probably is 80% the way there.
Edit: changing the PR so that instead of a new top-level command, this becomes
cargo update --workspace