Description
Problem
When using a Cargo.lock generated by 1.24.1, running cargo package
modifies Cargo.lock
and then fails without packaging anything. It's unexpected for cargo to modify any version-controlled file, and then to fail when the file has not been modified by the user. If the file is well-formed and semantically meaningful, it should be accepted without change by cargo package
. If it is not, cargo should abort without modifying the file.
My projects have a strict version compatibility requirement so Cargo.lock is built with an appropriate version of the Rust toolchain. Because there's no way to explicitly pin packages to minimum versions or to force versions of packages that work with a specific Rust version, the building of Cargo.lock has to be done with an older version of the toolchain and hand-editing, so using a newer version of cargo to generate the file isn't a possibility here.
Steps
- git clone https://github.com/bk2204/muter
- cd muter
- cargo package
- git diff
Possible Solution(s)
Avoid adding the generated header unless the Cargo.lock is intentionally regenerated or is missing.
Notes
Output of cargo version
:
cargo 1.45.1 (f242df6 2020-07-22)
This is with Rust 1.45.2 stable as a toolchain.