Skip to content

Dependency fails with "the feature doc_cfg has already been declared" #1289

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
pka opened this issue Feb 27, 2021 · 5 comments
Closed

Dependency fails with "the feature doc_cfg has already been declared" #1289

pka opened this issue Feb 27, 2021 · 5 comments

Comments

@pka
Copy link

pka commented Feb 27, 2021

Crate name: geozero
Build failure link: https://docs.rs/crate/geozero/0.7.2/builds/355163

Additional details:
geozero has the following Cargo.toml entry:

[package.metadata.docs.rs]
all-features = true
rustc-args = ["--cfg", "docsrs"] 

cfg(docsrs) is required for a doc.rs build of the dependency gdal: https://github.com/georust/gdal/blob/master/build.rs#L3

The failing tokio-stream crate does in fact set a feature twice based on docsrs: https://github.com/tokio-rs/tokio/blob/master/tokio-stream/src/lib.rs#L17-L23

But a local doc build is successful!

@jyn514
Copy link
Member

jyn514 commented Feb 27, 2021

This should be reported upstream to Tokio, we can't fix it on our end.

But a local doc build is successful!

Local builds don't pass --cfg docsrs by default.

@Nemo157
Copy link
Member

Nemo157 commented Feb 27, 2021

There is a bug somewhere here since tokio-stream successfully built its docs, and it appears to activate the cfg for its build. Maybe rustdoc allows duplicate features, while rustc doesn't?

@pka
Copy link
Author

pka commented Feb 27, 2021

This should be reported upstream to Tokio, we can't fix it on our end.

PR: tokio-rs/tokio#3561

But a local doc build is successful!

Local builds don't pass --cfg docsrs by default.

I tried to imitate docs.rs build with
cargo +nightly doc --all-features --config 'build.rustflags=["--cfg", "docsrs"]' -Z unstable-options

Am I missing something?

@Nemo157
Copy link
Member

Nemo157 commented Feb 27, 2021

I've opened rust-lang/rust#82588 for the rustdoc bug that allowed tokio-stream's docs to succeed.

Using cargo +nightly doc --all-features --config 'build.rustflags=["--cfg", "docsrs"]' -Z unstable-options on a crate that depends on tokio-stream I get the build failure, but at least on my machine I had to override CARGO_HOME for it to avoid loading my ~/.cargo/config, which sets target.x86_64-unknown-linux-gnu.rustflags overriding the build.rustflags config.

@pka
Copy link
Author

pka commented Feb 27, 2021

So nothing else to be done here, I think. Thanks @jyn514 and @Nemo157 for looking into it!

@pka pka closed this as completed Feb 27, 2021
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants