Skip to content

cargo publish fails if a feature enables a dev-dependency feature #13363

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

Closed
maia-s opened this issue Jan 28, 2024 · 4 comments
Closed

cargo publish fails if a feature enables a dev-dependency feature #13363

maia-s opened this issue Jan 28, 2024 · 4 comments
Labels
C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@maia-s
Copy link

maia-s commented Jan 28, 2024

Problem

If a feature enables a feature on a dev-dependency, cargo publish fails with an error that it's not a dependency. The crate works as expected otherwise.

Steps

  1. Have a dev-dependency with feature flags.
  2. Have a feature in your own crate that enables one of those features.
  3. Run cargo publish --dry-run

Possible Solution(s)

I made a separate crate for tests as a workaround.

Notes

No response

Version

cargo 1.77.0-nightly (1ae631085 2024-01-17)
release: 1.77.0-nightly
commit-hash: 1ae631085f01c1a72d05df1ec81f3759a8360042
commit-date: 2024-01-17
host: aarch64-apple-darwin
libgit2: 1.7.1 (sys:0.18.1 vendored)
libcurl: 8.4.0 (sys:0.4.70+curl-8.5.0 system ssl:(SecureTransport) LibreSSL/3.3.6)
ssl: OpenSSL 1.1.1w  11 Sep 2023
os: Mac OS 14.2.1 [64-bit]
@maia-s maia-s added C-bug Category: bug S-triage Status: This issue is waiting on initial triage. labels Jan 28, 2024
@weihanglo
Copy link
Member

Thanks for the report. This seems to be a duplicate of #12225

@epage
Copy link
Contributor

epage commented Jan 29, 2024

Hard to tell if its a dupe without a full reproduction case and error message.

@weihanglo weihanglo added S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. and removed S-triage Status: This issue is waiting on initial triage. labels Jan 29, 2024
@maia-s
Copy link
Author

maia-s commented Jan 30, 2024

Okay. To reproduce, create two new crates with cargo:

% cargo new --lib a
% cargo new --lib b

change a/Cargo.toml to this:

[package]
name = "a"
version = "0.1.0"
edition = "2021"

[features]
feature = ["b/feature"]

[dev-dependencies]
b = { path = "../b" }

change b/Cargo.toml to this

[package]
name = "b"
version = "0.1.0"
edition = "2021"

[features]
feature = []

My original dev-dependency was a proc-macro, but that's not required to reproduce.

Now enter the a crate. You can verify that cargo build, cargo build --features feature, cargo test and cargo test --features feature all run without error. Run cargo publish --dry-run

% cargo publish --dry-run --allow-dirty
    Updating crates.io index
warning: manifest has no description, license, license-file, documentation, homepage or repository.
See https://doc.rust-lang.org/cargo/reference/manifest.html#package-metadata for more info.
   Packaging a v0.1.0 (/private/tmp/a)
   Verifying a v0.1.0 (/private/tmp/a)
error: failed to verify package tarball

Caused by:
  failed to parse manifest at `/private/tmp/a/target/package/a-0.1.0/Cargo.toml`

Caused by:
  feature `feature` includes `b/feature`, but `b` is not a dependency

@epage
Copy link
Contributor

epage commented Jan 30, 2024

Thanks!

This does look like #12225 to me. Closing in favor of that. If there is a reason to keep this open, let us know!

@epage epage closed this as not planned Won't fix, can't repro, duplicate, stale Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

3 participants