packaging: omit generated Cargo.lock if binaries and examples are package-excluded #11557
Labels
A-lockfile
Area: Cargo.lock issues
C-feature-request
Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`
Command-package
S-triage
Status: This issue is waiting on initial triage.
Problem
When running
cargo package --no-verify --no-metadata -p <my_package>
Expected behavior: a generated
Cargo.lock
is produced for the package if and only if the package contains one or more examples or binaries.Observed behavior: If the package has
examples/**
, but has marked the path as excluded (https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields), aCargo.lock
is still generated despite the examples being excluded from the<package>.crate
file.Steps
No response
Possible Solution(s)
No response
Notes
This is admittedly an edge condition, but we have a CI flow where it is important to be able to avoid the
Cargo.lock
generation step. We are packaging multiple dependent crates from a workspace simultaneously for submission to an alternative registry with no API (direct registry index manipulation), so the failed registry lookups that occur duringCargo.lock
generation break our ability to package the crates simultaneously.We would not want to
.gitignore
the examples, as we want them there for developers of the crates. However, any other exclusion mechanism (if there are reasons not to overload https://doc.rust-lang.org/cargo/reference/manifest.html#the-exclude-and-include-fields) would be appropriate.The workaround we currently use is to avoid examples inside publishing crates, instead putting them in separate crate(s) in the same workspace.
This is related to:
cargo package
#7487Version
The text was updated successfully, but these errors were encountered: