Open bromls opened 1 year ago
This piece of code controls the behavior you described sits here
The fix might be simple. Call the clouse ignore_should_package(…)
earlier, and inside fn include_lockfile(…)
try to determine if target.src_path()
is ignored. Then determine the reult from these two booleans.
To me, it seems quite hacky but actually reasonable, since the package doesn't include any example ro binary anymore. However, I've seen several counter proposals advocating that every package even a library only package should commit its Cargo.lock
to VCS, specifically, #8728. I don't have an obvious answer at the time being.
I'm either misunderstanding something, or there's a misunderstanding. My understanding is that:
cargo package
should not package the Cargo.lock
for libraries (even if they have examples as long as those examples are not included in the package) from this issue #11557Cargo.lock
files should always be tracked in version control (like git) even for libraries because of reproducibility from #8728 linked aboveFor me, those 2 statements are not incompatible and that's what I expect from the following situation:
src
directory only, not the examples
directory).Cargo.lock
.Cargo.lock
for my continuous integration to be reproducible.Cargo.lock
to test early for breakages in compatible updates. But this is done as an isolated step to not break reproducibility.
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:
Version