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

Strange error message with features on dependencies #6941

Closed
ExpHP opened this issue May 14, 2019 · 2 comments
Closed

Strange error message with features on dependencies #6941

ExpHP opened this issue May 14, 2019 · 2 comments
Labels
C-bug Category: bug

Comments

@ExpHP
Copy link
Contributor

ExpHP commented May 14, 2019

Problem

cargo build produces a bizarre error message in a workspace with many generated internal dependencies, with features that activate features on their internal dependencies.

I've actually had this issue for a long time (a year?), but my prior attempts to minimize the code ended up causing the bug to disappear! Today I finally succeeded by making a very conservative minimization.

Steps

  1. Download: cargo-strange-error.tar.gz.
  2. The minimize branch will already be checked out. Run cargo build:
error: failed to select a version for `rsp2-array-types`.
    ... required by package `rsp2 v0.1.0 (/home/lampam/cpp/throwaway/cargo-strange-error)`
versions that meet the requirements `= 0.1.0` are: 0.1.0

the package `rsp2` depends on `rsp2-array-types`, with features: `rsp2-assert-close` but `rsp2-array-types` does not have these features.
  1. Observe that rsp2-assert-close never appears as a feature name in any Cargo.toml file. The error message is clearly nonsense!
rg '["/]rsp2-assert-close"'

Bonus round!

Here is an additional thing you can do that may help debug the issue:

Additional repro case

Now try checking out the master branch. This is the code prior to minimization. Observe the following:

  • On this branch, cargo build successfully begins building. (Just ctrl-c it; it will take a long time)
  • ...but now cargo build --features=nightly produces the exact same error message as above!

The only differences between minimize and master that I would imagine should affect cargo are the removal of build scripts, binaries, integration tests, and the changes listed here (which are mostly just removing external dependencies):

git diff master..minimize -- $(find . -name Cargo.toml)

Notes

The Cargo.toml files in this workspace contain some intimidating-looking [features] that look like this:

nightly = ["beta", "rsp2-array-types/nightly", "rsp2-array-utils/nightly", "rsp2-assert-close/nightly", "rsp2-minimize/nightly", "rsp2-newtype-indices/nightly", "rsp2-structure-io/nightly", "rsp2-structure/nightly", "rsp2-util-macros/nightly"]
beta = ["rsp2-array-types/beta", "rsp2-array-utils/beta", "rsp2-assert-close/beta", "rsp2-minimize/beta", "rsp2-newtype-indices/beta", "rsp2-structure-io/beta", "rsp2-structure/beta", "rsp2-util-macros/beta"]

These lines are programmatically generated. beta activates the /beta feature of every path dependency. nightly activates beta and the /nightly feature of every path dependency.

Cargo version

Tested on:

cargo 1.32.0 (8610973aa 2019-01-02)
cargo 1.36.0-nightly (759b6161a 2019-05-06)
@ExpHP ExpHP added the C-bug Category: bug label May 14, 2019
@ehuss
Copy link
Contributor

ehuss commented May 14, 2019

I think this is the same as #6915. There's something weird about passing a feature through to a dev-dependency.

@ExpHP
Copy link
Contributor Author

ExpHP commented May 14, 2019

Yep. I tried moving all of my internal dev-dependencies to regular dependencies and the error vanishes.

(well, a different error appears, but one that is correct; "rsp2-structure" mistakenly activates "rsp2-array-types/serde" instead of "rsp2-array-types/serde-support")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: bug
Projects
None yet
Development

No branches or pull requests

2 participants