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

Example specific dependencies #12894

Closed
alisomay opened this issue Oct 29, 2023 · 4 comments
Closed

Example specific dependencies #12894

alisomay opened this issue Oct 29, 2023 · 4 comments
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.

Comments

@alisomay
Copy link

alisomay commented Oct 29, 2023

Problem

I want to avoid using a workspace for this purpose but it would be really great if I could specify example specific dependencies.

One of the examples in my crate uses the latest version of nannou at the time of this post it is 0.18.1.
Another example uses bevy and the version is 0.11.
They have a clash on transative dependency web-sys.

error: failed to select a version for `web-sys`.
    ... required by package `wgpu v0.11.0`
    ... which satisfies dependency `wgpu_upstream = "^0.11"` of package `nannou v0.18.0`
    ... which satisfies dependency `nannou = "^0.18"` of package `libpd-rs v0.1.10 (/Users/vallahiboyle/Desktop/software/libpd-rs)`
versions that meet the requirements `^0.3.53` are: 0.3.57, 0.3.64, 0.3.63, 0.3.62, 0.3.61, 0.3.60, 0.3.59, 0.3.58, 0.3.56, 0.3.55, 0.3.54, 0.3.53

the package `wgpu` depends on `web-sys`, with features: `GpuBufferUsage` but `web-sys` does not have these features.


all possible versions conflict with previously selected packages.

  previously selected package `web-sys v0.3.61`
    ... which satisfies dependency `web-sys = "^0.3"` of package `bevy_render v0.11.0`
    ... which satisfies dependency `bevy_render = "^0.11.0"` of package `bevy_animation v0.11.0`
    ... which satisfies dependency `bevy_animation = "^0.11.0"` of package `bevy_gltf v0.11.0`
    ... which satisfies dependency `bevy_gltf = "^0.11.0"` of package `bevy_internal v0.11.0`
    ... which satisfies dependency `bevy_internal = "^0.11.0"` of package `bevy v0.11.0`
    ... which satisfies dependency `bevy = "^0.11"` of package `libpd-rs v0.1.10 (/Users/vallahiboyle/Desktop/software/libpd-rs)`

failed to select a version for `web-sys` which could resolve this conflict

Proposed Solution

The natural user facing solution feels like this to me:

# Common deps to all examples
[dev-dependencies]
cpal = "0.15.2"
rand = "0.8.5"
sys-info = "0.9.1"

[[example]]
name = "with_bevy"
path = "examples/with_bevy/main.rs"

# Example specific deps
[dev-dependencies.with_bevy]
bevy = "0.11"

[[example]]
name = "with_nannou"
path = "examples/with_nannou/main.rs"

# Example specific deps
[dev-dependencies.with_nannou]
nannou = "0.18"
nannou_audio = "0.18"

Notes

I know that creating a workspace is a workaround for this.
I'd like to know though that wouldn't you think it would be neat if we had this feature?
Would it be time consuming to implement?
If there is enough interest in this I can also volunteer to invest the time to make a PR.

Also I'd be really happy that if someone in the community would answer with the idiomatic workaround for this situation.

Thanks 🙏

@alisomay alisomay added C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage. labels Oct 29, 2023
@weihanglo
Copy link
Member

Haven't looked into the failure you got. By just reading the proposed solution and the issue title, I am assuming that this might be a duplicate of old good #1982?

@weihanglo
Copy link
Member

weihanglo commented Oct 29, 2023

Before any solution gets implemented, the current way to achieve it might be adding more features to your package to enable/disable dependencies, and having required-features for you Cargo targets.

@alisomay
Copy link
Author

I see.. it indeed is related, I didn't know about this issue.
I'll stick to the required-features work around for now.
Thank you.

@weihanglo
Copy link
Member

Let us have #1982 tracking cargo-target-specific dependencies altogether. We recently had rust-lang/rfcs#3374 which was closed due to implementation challenges with feature unification.

Thank for the reply. Close in favor of #1982.

@weihanglo weihanglo closed this as not planned Won't fix, can't repro, duplicate, stale Oct 29, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted` S-triage Status: This issue is waiting on initial triage.
Projects
None yet
Development

No branches or pull requests

2 participants