Specify the _exact_ version in Cargo?


#1

How do I specify the exact version in Cargo?

futures_preview= { version="0.3.0-alpha.10", features=["compat"]}

How do I tell cargo I really don’t want to pick up alpha.11?

The answer should be in here somewhere:
https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html


#2

https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#inequality-requirements

version = "=0.3.0-alpha.10"

#3

I feel some dark times coming on:

── futures v0.1.25
├── futures-preview v0.3.0-alpha.10
│ ├── futures-channel-preview v0.3.0-alpha.11
│ │ └── futures-core-preview v0.3.0-alpha.11
│ │ └── either v1.5.0


#4

This is not the direcrion time is meant to go in. I hope the futures guys know what they’re doing. I don’t want any of those Dr Who style time vortexes…

Ok, so while I can specify the top level I can’t hint that the lower levels should not upgrade :-S …


#5

You can with [patch.crates-io] override any dependency anywhere to your exact specification (e.g. git URL with a rev=hash).


#6

Apparently not using “yesterday’s” nightly of 2018-01-09 helps also… :face_palm:


#7

You can by adding them as direct dependencies with an exact version constraint as well, Cargo will unify the semver compatible constraints and only include one copy

futures-preview = { version = "=0.3.0-alpha.10", features = ["compat"] }
futures-core-preview = "=0.3.0-alpha.10"
...

arguably futures-preview should be using exact version constraints for its dependencies as well since there are no back-compat guarantees for these alphas, but bit late to do that for alpha.10 now.


#8

Thanks - that’s really neat.