feat(cargo-lock): support lockfile v4 - #1206
Conversation
| [[package]] | ||
| name = "toml" | ||
| version = "0.8.14" | ||
| source = "git+https://github.com/weihanglo/toml.git?branch=a-_%2B%23%24%29z#9e406273177740fa85b86b78e6d5105e932edef0" |
There was a problem hiding this comment.
Generated from https://github.com/weihanglo/toml/tree/a-_%2B%23%24)z.
|
Hmm… missing some commits. Wait a sec. |
| [[package]] | ||
| name = "url" | ||
| version = "2.5.2" | ||
| source = "git+https://github.com/weihanglo/rust-url.git?tag=a-_%2B%23%24%29z#54346fa288e16b25b71c45149d7067c752b450e0" |
There was a problem hiding this comment.
There was a problem hiding this comment.
Note that in 3bcf68b, a bug was identified, unrelated to lockfile v4. See the commit message for more.
@weihanglo it already supports this. |
Yeah but not for |
|
A lot of the code has been copied from there. It would be good to follow the same approach they're using. |
I am mostly thinking through this. The Cargo team has published a new crate https://crates.io/crates/cargo-util-schemas providing basic serialization schemas for common types. I wonder if we could get there so |
|
Sure, that looks potentially useful |
|
FWIW I took a look at Unfortunately, it doesn't seem ready for that as they just released semver breaking changes a week ago. In the meantime it doesn't otherwise seem to have types relating specifically to Cargo.lock, only Cargo.toml. |
That's true. I think maybe we should just copy over from there one more time 😞. |
While this was discovered that`Lockfile::load` cannot parse the unambiguous source id in dependency list correctly, this is not directly related to lockfile v4 so leave off for now. Example lockfile ```toml version = 3 [[package]] name = "a" version = "0.1.0" dependencies = [ "url 2.5.2 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] name = "b" version = "0.1.0" dependencies = [ "url 2.5.2 (git+https://github.com/servo/rust-url.git)", ] [[package]] name = "url" version = "2.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "22784dbdf76fdde8af1aeda5622b546b422b6fc585325248a2bf9f5e41e94d6c" [[package]] name = "url" version = "2.5.2" source = "git+https://github.com/servo/rust-url.git#54346fa288e16b25b71c45149d7067c752b450e0" ```
In 1.78.0 Cargo introduce v4 lockfile: rust-lang/cargo#12852 The v3-to-v4 change is minimal: encode URL params with URL encoding. However, roundtrip test failed because v4 we can only have one serialization implementation at a time. I don't know how to proceed. Maybe we could * Make v4 serialization the default when it becomes the default in Cargo * Provide API for people to generate different versions of lockfiles. * Work with upstream Cargo with an in-tree pacakge for lock serialization. (This is on me?) Opened this PR for discussion.
|
@tarcieri this is ready for review. Take your time :) Most of the code are copied or adapted from Note that I've identified a bug not related to lockfile format version: #1206 (comment) |
|
I'm busy for the rest of the week but will try to look this weekend |
|
Note for anyone stumbling on this PR when getting "parse error: invalid Cargo.lock format version: `4`" (and who control the workspace whose rust-version = "1.81" # ensure it stays in lockfile v3to the |
See rustsec/rustsec#1206 for details.
See rustsec/rustsec#1206 for details.
|
@weihanglo thank you! |
rustsec/rustsec#1206 was released in rustsec 0.30
rustsec/rustsec#1206 was released in rustsec 0.30
In 1.78.0 Cargo introduced v4 lockfiles: rust-lang/cargo#12852 The v3-to-v4 change is minimal: encode URL params with URL encoding.
In 1.78.0 Cargo introduce v4 lockfile:
rust-lang/cargo#12852
The v3-to-v4 change is minimal: encode URL params with URL encoding.
However, roundtrip test failed because v4 we can only have one
serialization implementation at a time.
I don't know how to proceed. Maybe we could
Opened this PR for discussion.