Skip to content
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

Feature that affects dev dependencies can't be enabled #6915

Open
dtolnay opened this issue May 7, 2019 · 1 comment
Open

Feature that affects dev dependencies can't be enabled #6915

dtolnay opened this issue May 7, 2019 · 1 comment
Labels
A-dependency-resolution A-features C-bug

Comments

@dtolnay
Copy link
Member

@dtolnay dtolnay commented May 7, 2019

Problem

I have crates A, B, C with the following manifests:

[package]
name = "a"
version = "0.0.0"

[features]
f = ["b/f"]

[dependencies]
b = { path = "../b" }
[package]
name = "b"
version = "0.0.0"

[features]
f = ["c/f"]

[dev-dependencies]
c = { path = "../c" }
[package]
name = "c"
version = "0.0.0"

[features]
f = []

Expected behavior: I believe it should be possible to build crate A. Running cargo check in crate A should build crate A without feature f and crate B without feature f. Running cargo check --features f in crate A should build crate A with feature f and crate B with feature f, but not C because that is a dev dependency of a dependency.

Actual behavior: crate A cannot be built, with or without f.

$ cargo check

error: failed to select a version for `b`.
    ... required by package `a v0.0.0 (/path/to/a)`
versions that meet the requirements `= 0.0.0` are: 0.0.0

the package `a` depends on `b`, with features: `c` but `b` does not have these features.


failed to select a version for `b` which could resolve this conflict

Possible objection: "but B/f requires C/f, we can't enable B/f without building C!" I don't think this is valid because cargo check --features f in crate B will already build crate B with feature f enabled without building the dev dependency C.


Notes
cargo 1.36.0-nightly (beb8fcb 2019-04-30)

@dtolnay dtolnay added the C-bug label May 7, 2019
dtolnay referenced this issue in serde-rs/serde May 7, 2019
Without this:

    error: failed to select a version for `serde_test_suite`.
        ... required by package `serde_test_suite-tests v0.0.0`
    versions that meet the requirements `= 0.0.0` are: 0.0.0

    the package `serde_test_suite-tests` depends on `serde_test_suite`, with features: `serde` but `serde_test_suite` does not have these features.

    failed to select a version for `serde_test_suite` which could resolve this conflict

Seems like a Cargo bug -- I will minimize and report.
@ehuss ehuss added the A-features label May 8, 2019
ExpHP added a commit to ExpHP/rsp2 that referenced this issue May 14, 2019
This should finally fix the nightly configuration on travis
BusyJay added a commit to tikv/grpc-rs that referenced this issue Jul 24, 2019
This PR breaks the circle dependencies between grpcio and grpcio-proto
by adding a new crate named tests and examples. We can bring things back
once rust-lang/cargo#6915 is fixed.

The new structure also fixes a problem that crates.io denies to accept
circle dependencies in dev-dependencies. More see rust-lang/cargo#4242.

This PR also updates protobuf-build to the latest version. Note that
until protobuf-build is released, we can't release grpcio-proto.
BusyJay added a commit to tikv/grpc-rs that referenced this issue Jul 24, 2019
This PR breaks the circle dependencies between grpcio and grpcio-proto
by adding a new crate named tests and examples. We can bring things back
once rust-lang/cargo#6915 is fixed.

The new structure also fixes a problem that crates.io denies to accept
circle dependencies in dev-dependencies. More see rust-lang/cargo#4242.

This PR also updates protobuf-build to the latest version.
BusyJay added a commit to tikv/grpc-rs that referenced this issue Jul 24, 2019
This PR breaks the circle dependencies between grpcio and grpcio-proto
by adding a new crate named tests and examples. We can bring things back
once rust-lang/cargo#6915 is fixed.

The new structure also fixes a problem that crates.io denies to accept
circle dependencies in dev-dependencies. More see rust-lang/cargo#4242.

This PR also updates protobuf-build to the latest version.
@Eh2406 Eh2406 added the A-dependency-resolution label Aug 13, 2019
@apopiak
Copy link

@apopiak apopiak commented Mar 20, 2020

Is there a known workaround for this except moving the deps to the dependencies section?

johnpmayer added a commit to johnpmayer/bevy_networking_turbulence that referenced this issue Feb 14, 2021
near-bulldozer bot pushed a commit to near/nearcore that referenced this issue Jun 2, 2021
We're sort of in a weird spot as it is, we have features within `nearcore` that are required but can't be enabled if they depend on crates listed under `dev-dependencies` (bug in cargo: rust-lang/cargo#6915). Temporarily listing them under `dependencies`, fixed the CI testing failures we had while working on #4292 (same error @ailisp highlighted: #4333 (comment)), but as pointed out in #4331 (comment), this method should be out of the question. If we remove it, however, we can't work with the tests that depend on those features.

This PR moves the _previously top-level_ tests into a new crate to have better dependency and feature handling as @matklad suggested

> * [move tests from `/test` folder somewhere -- either to some of the existing packages (neard perhaps?) or into a new `integration-tests` package](#4292 (comment))

This would ensure we have dependencies like `testlib`, `runtime-params-estimator` and `restored-receipts-verifier` that are only needed for testing and depend on nearcore without cyclic dependency issues while having all features relevant to testing in order.

The features within `neard` have been reduced to proxies to `nearcore` features, which partially resolves #4325 (though the intent for that has morphed a bit). This also makes for a cleaner dependency graph from `neard` perspective, removing extraneous dependencies that were previously required.

I also noticed removed the `old_tests` feature that should've been removed along with the rest of it in #928.

Updated some docs and code comments referencing the old `neard` path too.
vherbert pushed a commit to vherbert/frost-dalek that referenced this issue Nov 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-dependency-resolution A-features C-bug
Projects
None yet
Development

No branches or pull requests

4 participants