Optional dependencies with same name

Imagine that you have something like:

[dependencies.clap]
version = "2"
optional = true

[build-dependencies.clap]
version = "2"
default-features = false
optional = true

Then you reference clap dependency from one of your features, which one would be referenced? Both?

P.S. this is not entirely theoretical case, see https://pagure.io/fedora-rust/rust2rpm/pull-request/60#comment-67442

Features are currently conflated across dependencies / dev-dependencies / build-dependencies. There are a few issues about this in the Cargo issue tracker – see rust-lang/cargo#4361, rust-lang/cargo#4664, rust-lang/cargo#5730. So:

[features]
x = ["clap/..."]

would affect both.

This may change in the future.

IIUC, that technically it is merged, Right?

So if one has default-features=false and other doesn’t, cargo will always make sure that clap always have default-features enabled. Right?

You could try it to make sure, but yes that is my understanding.

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.