-
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
Heuristics to include Cargo.lock or not in a package are suboptimal #13447
Comments
While the sympton is different, there is some overlap in the solution space with #13306 (see also https://blog.rust-lang.org/inside-rust/2024/02/13/this-development-cycle-in-cargo-1-77.html#rfc-3537-make-cargo-respect-minimum-supported-rust-version-msrv-when-selecting-dependencies). |
Somewhat related (one could also use the |
@epage So as you said the focus should be on this issue (in #14769), how should this move forward? For this specific issue it seems like simply having [package]
publish-lockfile = true would solve the issue. If not specified, it would use the current heuristic, otherwise whatever value was provided. If the naming and behaviour makes sense to you, I would be happy to implement that. |
I've proposed we discuss this in the next Cargo team meeting. I would go with unconditionally including |
Sounds good to me |
@sdroege we discussed this in today's team meeting and have Accepted this issue, opening the way for moving forward with it. The original motivation for the heuristic is recorded in #5093 (comment). This was intended purely for |
Great, thanks! I'll take a look at providing a PR then. EDIT: Mostly a matter of updating all the tests that assume no |
See #14815 |
Originally it was only included for packages that have executables or examples for `cargo install`, however this causes inconsistencies and is kind of unexpected nowadays, e.g. with cdylib crates. Including it always only slightly increases the crate size and allows for all crates to know a set of dependency versions that were working, which can make regression tracking easier. Fixes rust-lang#13447
Originally it was only included for packages that have executables or examples for `cargo install`, however this causes inconsistencies and is kind of unexpected nowadays, e.g. with cdylib crates. Including it always only slightly increases the crate size and allows for all crates to know a set of dependency versions that were working, which can make regression tracking easier. Fixes rust-lang#13447
### What does this PR try to resolve? Originally it was only included for packages that have executables or examples for `cargo install`, however this causes inconsistencies and is kind of unexpected nowadays, e.g. with cdylib crates. Including it always only slightly increases the crate size and allows for all crates to know a set of dependency versions that were working, which can make regression tracking easier. Fixes #13447 ### How should we test and review this PR? The existing tests are covering this change in all kinds of various already, and one test that previously asserted that there is *no* Cargo.lock for library crates was changed to explicitly check for the new behaviour.
Problem
Context is: https://gitlab.freedesktop.org/gstreamer/gst-plugins-rs/-/issues/499
The setup here is a workspace with multiple cdylib/staticlib/rlib crates. When publishing them, the ones with an example or binary will have their Cargo.lock included in the package, the others not:
This seems a bit arbitrary in this situation. Some of the crates have examples, some not 🤷
In practice this causes problems if people get the crates from crates.io and try to build the cdylib/staticlib, e.g. via cargo-c, and use
--frozen
to ensure that the sameCargo.lock
is used as during publishing.Steps
cargo publish --dry-run
and check whether theCargo.lock is included in
target/package` (it is not)cargo publish --dry-run
and check whether theCargo.lock is included in
target/package` (it is included now)Possible Solution(s)
I would suggest to update the heuristic above to either include cdylib/staticlib crates, and/or to provide some kind of configuration in
Cargo.toml
whether theCargo.lock
should be included or not.If something is decided, I'd be happy to implement this.
Notes
No response
Version
The text was updated successfully, but these errors were encountered: