-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Remove [root]
section from Cargo.lock
file
#4563
Comments
@alexcrichton do you also think that a year is a long enough grace period? To be clear, new Cargos will always read the old lockfiles, but a Cargo from a year ago will fail to read the new lockfile. |
Whoa I had no idea that we had support for this! In that case I think we're probably in a pretty good situation. Although I think we may be missing one piece to flip the switch. Right now while an older Cargo will parse a root-missing lockfile, will it also generate one? The problem we just want to avoid is that if you build with different verisons of Cargo the lock file oscillates between two different formats. If older Cargo though generates a lock file without |
This is exactly what was implemented back then, yeah! |
@matklad Mind if I give this a go? :) |
@raytung sure, it's yours :) |
Remove root from cargo lock Removing [root] section from Cargo.lock for #4563 Tests of interest has been updated accordingly, especially [tests/lockfile-compat.rs#oldest_lockfile_still_works](https://github.com/rust-lang/cargo/compare/master...raytung:remove-root-from-cargo-lock?expand=1#diff-48866d1891f97cb799dd0ca7148d1eefR10)
Fixed in #4571? |
Indeed! |
This is a problem for me. This means that the current nightly version of Cargo actively breaks compatibility with older versions of Rust. Every time I run Additionally, it means I can't work on changes in the new version of Rust, then back-port those changes; I have to work exclusively in an older version. So far as I'm aware, there's no way to prevent Cargo from messing with the lock file. If I make the file read-only, The question on this issue was "if we aren't using this, why not remove it?" My question is: "if it doesn't hurt anything, why remove it?" |
So even with
This is true: this change makes lockfiles generated by newer Cargos incompatible with older Cargos. Could you elaborate what is the backwards compatibility story for your use case? Why do you need to publish updates,which are to be build with a year's old toolchain?
The main (not very strong) motivation here is to prevent the user from interpreting the |
At the moment we can't build old projects with $ cd old_project
$ rustup run nightly cargo build --frozen
error: the lock file needs to be updated but --frozen was passed to prevent this |
As noted,
I said I'd support 1.11. I have no technical reason to break that promise: there is nothing my code is doing that can't be done in 1.11. (Even then, it's 1.11 due to dependencies.) I personally loathe it when people break back compat without a damn good reason for doing so, so I take my promises in this regard very seriously. It's not about needing to build on a year-old toolchain, it's about there being no reason to not build on a year-old toolchain.
This sounds more like "workspaces and The problem here isn't that Cargo isn't writing |
Don't update lockfiles from previous Cargo versions if `--locked` is passed Recently, we've stopped outputting `[root]` section to Cargo.lock files. The problem with this is that somebody might want to have a Cargo.lock file with a `[root]` section for compatibility with older Cargos, but at the same time use newer Cargo to build the crate. In this case, newer Cargo would remove `[root]` from the lockfile. Such updating of the lockfiles to the latest versions is a reasonable behavior, but it might be useful to be able to override it with `--locked` flag. Context: #4563 (comment) r? @alexcrichton
Newer versions of cargo recently removed the ability to understand the `[root]` section of Cargo.lock files, which is particularly relevant when either `cargo --frozen` and/or `cargo --locked` are specified, and the failure/inability to download a new index will cause the whole build to fail with "error: the lock file needs to be updated but --frozen was passed to prevent this" (cf. rust-lang/cargo#4563). * REMOVE `[root]` section from our top-level `Cargo.lock` file. * FIXES #24608: https://bugs.torproject.org/24608
Newer versions of cargo recently removed the ability to understand the `[root]` section of Cargo.lock files, which is particularly relevant when either `cargo --frozen` and/or `cargo --locked` are specified, and the failure/inability to download a new index will cause the whole build to fail with "error: the lock file needs to be updated but --frozen was passed to prevent this" (cf. rust-lang/cargo#4563). * REMOVE `[root]` section from our top-level `Cargo.lock` file. * FIXES #24608: https://bugs.torproject.org/24608
Hi! We (The Tor Project) appear to be having the same bug as @DanielKeep (and reasoning for backwards compatibility with the lockfiles which are now in our older, maintenance-only branches). However, instead of with Should I make a new ticket for this issue? |
Reopening this seems like a good start :) |
My first thought was that we patched Given that there was an additional fix for this issue for cases in which the My next step is going to be attempting to reproduce and reduce the circumstances in which the failure tor is seeing in travisci occurs. |
@isislovecruft , on Traivis I see
So this means that the test is using the fresh nightly version of Cargo. Does it mean that this is a fresh regression? |
Hm, I am now remembering a PR which removes some checksum checking from the lockfile, I wonder if it is the culprit... |
@matklad I noticed cargo was updated in rust-lang/rust 8 days ago, which matches when tor started seeing travis fail ("This is causing build errors on Travis, which picked up the newest cargo nightly a week ago.") |
Yep, the commit I am talking about is a0dfbb7 |
Aaaahhh ok, that sounds like a new issue then? |
@carols10cents seems so! If tor faced this issue and they are testing on nightly/beta, then they would have caught it ages ago. |
Ok I've opened a new issue: #4815 and I'm reclosing this one :) |
Support for reading rootless lock files was added in cargo PR 3031, which landed in cargo 0.14, released in November of 2016. Cargo stopped generating the root section in cargo PR 4571, which landed in cargo 0.23. refs rust-lang/cargo#3031 refs rust-lang/cargo#4563 refs rust-lang/cargo#4571
Cargo.lock includes
[root]
section which is no longer used for anything, because it became obsolete when Cargo workspaces were implemented.About a year ago, support for rootless lockfiles was implemented: 5e644df.
However, by default Cargo still adds an arbitrary root to be compatible with older Cargos. Given that we have a year's worth of new Cargos, I think we can safely switch to rootless lockfiles.
This code should be removed:
cargo/src/cargo/ops/lockfile.rs
Lines 45 to 49 in d7e3b7f
However, we should make sure that Cargo is still able to read a lockfile with a root section (there's a test for this).
The text was updated successfully, but these errors were encountered: