You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using package.exclude or package.include (which will exclude everything not included) on a file that is referenced by a Cargo target with a default path (not specifying a path), cargo publish will fail.
Steps
Initialize an empty crate with the following Cargo.toml file:
[package]
name = "test-publish-target"version = "0.0.0"edition = "2021"exclude = ["tests"]
[[test]]
name = "test"test = false
Run cargo publish --dry-run
Possible Solution(s)
Specifying a path solves the problem:
[[test]]
name = "test"path = "tests/test.rs"test = false
This should be improved by #10090, which provides a better error message. For example,
error: failed to verify package tarball
Caused by:
failed to parse manifest at `/projects/issue10182/target/package/issue10182-0.1.0/Cargo.toml`
Caused by:
- can't find `test` test, specify test.path+ can't find `test` test at `tests/test.rs` or `tests/test/main.rs`. Please specify test.path if you want to use a non-default path.
We may check all paths of possible Cargo targets (either specified or unspecified) against exclude/include fields. We could share the ignore logic from cargo::core::path::PathSource to cargo::util::toml::targets. Then use the same ignore rule to suppress targets that are excluded.
Alternatively, we can craft a specialized message for missing file of a Cargo target for cargo package, telling that this may be due to file being excluded.
Both of the solution seem a bit overkill to me personally from Cargo implementation side.
Problem
When using
package.exclude
orpackage.include
(which will exclude everything not included) on a file that is referenced by a Cargo target with a default path (not specifying a path),cargo publish
will fail.Steps
Cargo.toml
file:cargo publish --dry-run
Possible Solution(s)
Specifying a path solves the problem:
Notes
This was also reported here: https://users.rust-lang.org/t/cargo-publish-with-excluded-benchmark-fails-validation/53444. But I didn't find a corresponding issue report.
Version
The text was updated successfully, but these errors were encountered: