-
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 from cargo lock #4571
Conversation
r? @matklad (rust_highfive has picked a reviewer for you, use r? to override) |
src/cargo/ops/lockfile.rs
Outdated
let toml = toml::Value::try_from(WorkspaceResolve { | ||
ws: ws, | ||
resolve: resolve, | ||
use_root_key: use_root_key, | ||
use_root_key: false, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this field can be removed now as well?
@@ -971,7 +971,7 @@ fn stale_cached_version() { | |||
let rev = repo.revparse_single("HEAD").unwrap().id(); | |||
|
|||
File::create(&foo.root().join("Cargo.lock")).unwrap().write_all(format!(r#" | |||
[root] | |||
[[package]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it true that changes in tests are mostly cosmetics? That is, the tests pass with [root]
as well as with [[package]]
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it. I made the same change against master branch and the test passes without a hitch
@@ -328,7 +328,7 @@ Cargo will take the latest commit and write that information out into our | |||
`Cargo.lock` when we build for the first time. That file will look like this: | |||
|
|||
```toml | |||
[root] | |||
[[package]] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent catch! I haven't thought of the docs at all!
A workspace with an old-style lock file should get transformed by |
@lukaslueg yeah, I think it makes sense to add this test as well. |
tests/lockfile-compat.rs
Outdated
for (l, r) in expected_lock_file.lines().zip(lock.lines()) { | ||
assert!(lines_match(l, r), "Lines differ:\n{}\n\n{}", l, r); | ||
} | ||
for cargo_command in cargo_commands { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I think this won't work as expected, because the second time around the lockfile will already be updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah! of course. I'll probably create a helper method and loop through the vector.
LGTM! I'll tag this relnotes: it's probably worth mentioning that lockfiles might loose @bors r+ |
📌 Commit cab464e has been approved by |
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)
☀️ Test successful - status-appveyor, status-travis |
Cheers @matklad and @lukaslueg! 😄 |
Hi I was recently hit by this budziq/rust-skeptic#65. I'm parsing cargo.lock What would be the correct way to get versions of all deps in the workspace? |
@budziq |
Thanks @matklad! Is it's output stable? |
@alexcrichton sometimes I think we should add a
comment to the top of our lockfiles ... :) |
@budziq yep! Moreover, it'll yell at you if you don't pass the |
Thanks! |
1.22 removed [root]: rust-lang/cargo#4571 The old file is compatible, cargo updates it when it runs, which means I can't release because the workspace isn't clean.
1.22 removed [root]: rust-lang/cargo#4571 The old file is compatible, cargo updates it when it runs, which means I can't release because the workspace isn't clean.
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
Removing [root] section from Cargo.lock for #4563
Tests of interest has been updated accordingly, especially tests/lockfile-compat.rs#oldest_lockfile_still_works