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

Platform specific dependencies documentation unclear #5005

Closed
1 task
gnzlbg opened this issue Feb 4, 2018 · 6 comments
Closed
1 task

Platform specific dependencies documentation unclear #5005

gnzlbg opened this issue Feb 4, 2018 · 6 comments
Labels
A-documenting-cargo-itself Area: Cargo's documentation S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.

Comments

@gnzlbg
Copy link
Contributor

gnzlbg commented Feb 4, 2018

See here: https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html

I depend on two platform specific crates, A and B:

[target.'cfg(foo)'.dependencies]
crate_a = "0.4.0"

[target.'cfg(bar)'.dependencies]
crate_b = "1.0.1"

Crate A has one feature "baz" enabled by default. I want to disable it by default, and then re-export it as my own feature baz.

IIUC I could do this to disable it by default:

[dependencies.crate_a]
default-features = false
  • I am not sure whether this works for platform specific dependencies as well, the docs don't say. Cargo produces this warning:
warning: dependency (crate_a) specified without providing a local path, Git repository, or version to use. This will be considered an error in future versions

After I disable all default features of crate A, I have no idea how to re-export them. The docs say I should do:

[features]
baz = [ "crate_a/baz" ] 

but what happens when I am on a target that is using crate_b and crate_a does not exist ? Is that still ok? EDIT: with the fix below it seems to "just work" but I am not sure if this is some behavior I can rely on. Like what happens when someone in a platform that uses crate_b enables the feature baz ?

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Feb 4, 2018

Ok so it seems that I have to do:

[target.'cfg(foo)'.dependencies.crates_a]
crate_a = "0.4.0"
default-features = false

to disable the features of a platform-specific dependency. An example of this in the docs would have helped.

@gnzlbg
Copy link
Contributor Author

gnzlbg commented Feb 4, 2018

Maybe related to this #1197 ?

@alexcrichton alexcrichton added the A-documenting-cargo-itself Area: Cargo's documentation label Feb 4, 2018
@ferjm ferjm mentioned this issue Jul 11, 2018
6 tasks
@stale
Copy link

stale bot commented Sep 17, 2018

As there hasn't been any activity here in over 6 months I've marked this as stale and if no further activity happens for 7 days I will close it.

I'm a bot so this may be in error! If this issue should remain open, could someone (the author, a team member, or any interested party) please comment to that effect?

The team would be especially grateful if such a comment included details such as:

  • Is this still relevant?
  • If so, what is blocking it?
  • Is it known what could be done to help move this forward?

Thank you for contributing!

(The cargo team is currently evaluating the use of Stale bot, and using #6035 as the tracking issue to gather feedback.)

If you're reading this comment from the distant future, fear not if this was closed automatically. If you believe it's still an issue please leave a comment and a team member can reopen this issue. Opening a new issue is also acceptable!

@stale stale bot added the stale label Sep 17, 2018
@gnzlbg
Copy link
Contributor Author

gnzlbg commented Sep 17, 2018

Is this still relevant?

Yes.

If so, what is blocking it?

Nothing.

@stale stale bot removed the stale label Sep 17, 2018
@epage
Copy link
Contributor

epage commented Oct 17, 2023

Unsure if this would be better in https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html or https://doc.rust-lang.org/cargo/reference/features.html#dependency-features

Its also not quite clear to me what is needing documenting. That default-features = false can be used? That seems like just-another dependency field. @gnzlbg could you help me understand what the point of confusion was.

@epage epage added the S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request. label Oct 17, 2023
@weihanglo
Copy link
Member

The doc has been improved since then, and this has been stale for a while. Given there is no response from the original author, I am going to close this. Feel free to open a new issue if there are still some confusions.

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale Jul 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-documenting-cargo-itself Area: Cargo's documentation S-needs-info Status: Needs more info, such as a reproduction or more background for a feature request.
Projects
None yet
Development

No branches or pull requests

4 participants