Skip to content

Example specific dependencies #12894

@alisomay

Description

@alisomay

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 🙏

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-feature-requestCategory: proposal for a feature. Before PR, ping rust-lang/cargo if this is not `Feature accepted`S-triageStatus: This issue is waiting on initial triage.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions