-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
allow .cargo-checksum.json to be missing #11063
Comments
On the other hand, I feel like directory source (a.k.a. vendored source) is not meant to be under any manual modification. The purpose of Also worth mentioning that personally I see what
I am more curious about the use case here. Would you like to elaborate more on what verification you want to achieve? |
The use case is to use the vendor/ directory for broad source replacement. It is by far the simplest way to perform source replacement across a large number of crates. The specific flow for why I'm using it is for do package verification of multiple crates in a workspace together before publishing. The full flow is here: #1169 (comment). Maybe cargo vendor should have an Maybe cargo vendor shouldn't be the one adding this file and instead the file should be included in all .crate files at the point of packaging. It is somewhat odd that it is tacked on only when building the vendor directory. |
Thank you for the information! Let me simplify what I understand so far: You want a The Cargo Team are working on improving experience of publishing. For example, #11062 is an attempt to wait for a publish propagaing to crates.io index. There is also an external tool |
Improving cargo publish to support workspaces as first class would be a wonderful but #1169 has been open for 8 years so I think it's a little more complex of an issue. However, this issue is primarily about the
After thinking about this file more it feels like it's being generated in the wrong place. Shouldn't a checksum file for a crate be available at all times in the If packaging generated the file it would:
|
Thank you for the thorough investigation! It does point out the discrepancy between different sources on handling checksums, which has rooms to improve. So far, I see several proposals around checksums, and each of them does a bit differently. Before we proceed, I would like to take a step back to make sure we are on the same page. Here are a few questions we need to clarify:
I am sorry for throwing a bunch of questions here, but it is important to frame the question in a correct scope before we diverge. It also helps we focus on what we care about instead of going into yak shaving. Below are some responses for "the oddity" of Expand
I would say it is not an issue for the current implementation of
That's true. However,
That's really fascinating! I believe this is a good direction for vendor crates. There is also a previous work on making registry sources read-only though some difficulties emerged. I would probably say we can do experiments on this!
I doubt that this is the responsibility of BTW, "validation" here needs a clearer definition.
This probably doesn't really solve the problem. As an end user of |
Got sent here by https://thomask.sdf.org/blog/2023/11/14/rust-without-crates-io.html |
It's a wonderful work around. Given that the contents of the file is already optional, is it controversial to make the file optional? |
The problem is even though checksum verification of files in a
It allows developers to build a
Cost is minimal. The change only requires checking if the file exists before reading it, and using an empty default value instead of a loaded value. The change would be limited to one code location. |
Tl;Dr of the linked blog post, so we have all pertinent information in-thread: Those distribution have policies that everything in the ecosystem must be buildable without internet access, so they do ecosystem wide patching to replace crates.io with a (single, os-wide shared) vendor folder. Given that empty contents are currently accepted, making the entire file optional is not a functional change. instead it is merely taking the optionality of checksums all the way to its logical conclusion. I am certain packagers would appreciate a way to generate a useful checksum file (e.g. via the suggested |
I did some digging to find the relevant parts of the code. Checksum file is opened here: cargo/src/cargo/sources/directory.rs Lines 179 to 187 in d794e1f
cargo/src/cargo/sources/directory.rs Lines 31 to 34 in d794e1f
From other comments in Other random, relevant tidbits gleaned during my expedition:
|
Problem
Cargo requires
.cargo-checksum.json
to be present in all crates vendored in thevendor/
directory but provides no convenient means for generating the file when manually adding a crate to the directory.Adding crates to the
vendor/
directory manually is sometimes necessary when building local vendor directories to be used for source replacement, but having to manually create a.cargo-checksum.json
is difficult.It is worth noting that cargo allows the
.cargo-checksum.json
file to contain no checksums, i.e.{"files":{}}
and so the convenient way to add crates to the vendor directory without actually building the file is with:Other than this one file building custom vendor/ directories for source replacement is very convenient and easy thanks to the fact that .crate files can be simply extracted into the vendor/ directory. It should be convenient and simple to do this without writing mostly empty .json files into the tree.
Proposed Solution
Allow the
.cargo-checksum.json
file to be missing. If it is present use its checksums. If it is not present, continue. This is the same behavior as what happens if a checksum isn't found in the file, and so this is not a breaking change and barely any new functionality.Notes
Discussion on Zulip: https://rust-lang.zulipchat.com/#narrow/stream/246057-t-cargo/topic/cargo.20vendor.20for.20multi-crate.20workspace.20package.20verification/near/297866366
The text was updated successfully, but these errors were encountered: