Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cargo.lock is modified after running cargo package #8610

Closed
bk2204 opened this issue Aug 11, 2020 · 5 comments
Closed

Cargo.lock is modified after running cargo package #8610

bk2204 opened this issue Aug 11, 2020 · 5 comments
Labels
A-lockfile Area: Cargo.lock issues C-bug Category: bug

Comments

@bk2204
Copy link
Contributor

bk2204 commented Aug 11, 2020

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

  1. git clone https://github.com/bk2204/muter
  2. cd muter
  3. cargo package
  4. 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.

@Eh2406
Copy link
Contributor

Eh2406 commented Aug 17, 2020

Can you elaborate on how you ended up pind to a version from 2.5 years ago?

@bk2204
Copy link
Contributor Author

bk2204 commented Aug 17, 2020

Sure. I have for many years supported certain Linux distros and their toolchains for a defined period. This policy has been in place for longer than Rust has been around. 1.24.1 is the version in Debian stretch, and therefore I supported it until Debian buster had been released for a year. I now support 1.34.2 and will until Debian bullseye has been released for a year.

I realize that this is not Rust upstream's preferred support policy, but I value compatibility with major Linux distros, especially Debian.

@ehuss ehuss added the A-lockfile Area: Cargo.lock issues label Aug 19, 2020
@Eh2406
Copy link
Contributor

Eh2406 commented Aug 21, 2020

We talked about this in the Cargo Team meeting. We believe that it will be accepted without change if you pass the --locked flag, and the --frozen flag will abort without modifying the file. I hope that successfully gets you unstuck.

More generally there are plans in the works (#8554 for example) to make the way we upgrade the lockfile more consistent. Unfortunately for you, they are likely to be more consistently updating to newer formats. I am sorry.

@bk2204
Copy link
Contributor Author

bk2204 commented Aug 22, 2020

I did discover --locked after searching the source code. It wasn't apparent to me from the description in the --help output that it would have that effect; I didn't interpret “Require Cargo.lock is up to date” as indicating it wouldn't be modified. Maybe changing the description to “don't modify Cargo.lock; fail if out of date” or something similar would indicate this better.

@epage
Copy link
Contributor

epage commented Nov 2, 2023

With the existence of --locked, I'm taking it there isn't anything more to do for this and am closing it. If there is something I missed, let us know!

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Nov 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-lockfile Area: Cargo.lock issues C-bug Category: bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants