-
Notifications
You must be signed in to change notification settings - Fork 2.6k
dep-features can't reference dev-dependencies features #9060
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
Comments
dev-dependency features can not be enabled conditionally currently, see rust-lang/cargo#9060
dev-dependencies only exist when building the crate that defines them, right? When building |
Oh, that explains this. But then I can't use features of crates which conditionally enable features in their dev-dependencies, right? In this case, I don't know if this approach should be encouraged, but the purpose of this is obviously to test the I think we should either
|
Maybe the problem becomes more clear when # cookie/Cargo.toml
[features]
session = [] # awesome/Cargo.toml
[features]
session = ["cookie/session", "tide"]
[dependencies.tide]
path = "../tide"
optional = true
[dev-dependencies.cookie]
path = "../cookie" # app/Cargo.toml
[dependencies.awesome]
path = "../awesome"
features = ["session"] Now |
dev-dependency features can not be enabled conditionally currently, see rust-lang/cargo#9060
One workaround is for |
This bug is now blocking me, because I need to enable a feature of a dependency which depends on my crate itself. This means I can only use dev-dependencies, because otherwise it would be a dependency cycle. But the features don't work correctly for dev-dependencies. # riker
[features]
default = []
tokio_executor = ["riker-macros/tokio_executor"]
[dependencies]
riker-macros = { path = "riker-macros" } # riker/riker-macros
[features]
default = []
tokio_executor = ["tokio", "riker-testkit/tokio_executor", "riker/tokio_executor"]
# ...
[dev-dependencies]
riker = { path = ".." }
|
should be added back when rust-lang/cargo#9060 is solved
I guess the solution to this would be to ignore "cookie/session" as a feature switch when building "awsome" as a dependency because it references a feature of a dev-dependency, which is not available when building as a dependency. I will see if I can make a PR for this. |
It looks like this was fixed in 2eee644 which was released in 1.58 However, we should probably add a test for this case. |
Say we have:
activating a feature in the dev-dependency through a feature in awesome does not work:
The error message is this:
Notes
Output of
cargo version
:cargo 1.49.0-nightly (2af662e22 2020-11-12)
The text was updated successfully, but these errors were encountered: