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

Having rand 0.5 and rand 0.6 with default features turned off in the crate graph results in a compliation error #645

Closed
koute opened this issue Nov 16, 2018 · 14 comments

Comments

@koute
Copy link
Contributor

koute commented Nov 16, 2018

  1. Create a crate bar and depend on rand 0.5.
  2. Create a crate foo and depend on rand 0.6 with default-features = false and on bar.
  3. Compile foo.

Resulting error:

$ cargo check
    Checking rand v0.6.0
error[E0277]: the trait bound `rngs::jitter::TimerError: std::error::Error` is not satisfied
   --> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.0/src/rngs/jitter.rs:267:9
    |
267 |         Error::with_cause(ErrorKind::Unavailable,
    |         ^^^^^^^^^^^^^^^^^ the trait `std::error::Error` is not implemented for `rngs::jitter::TimerError`
    |
    = note: required because of the requirements on the impl of `core::convert::From<rngs::jitter::TimerError>` for `alloc::boxed::Box<(dyn std::error::Error + core::marker::Send + core::marker::Sync + 'static)>`
    = note: required because of the requirements on the impl of `core::convert::Into<alloc::boxed::Box<(dyn std::error::Error + core::marker::Send + core::marker::Sync + 'static)>>` for `rngs::jitter::TimerError`
    = note: required by `rand_core::Error::with_cause`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0277`.
error: Could not compile `rand`.

To learn more, run the command again with --verbose.

Automatic reproduction:

cargo new --lib foo
cargo new --lib bar

echo 'rand = "0.5"' >> bar/Cargo.toml
echo 'rand = { version = "0.6", default-features = false }' >> foo/Cargo.toml
echo 'bar = { path = "../bar" }' >> foo/Cargo.toml

cd foo
cargo check

Rust version:

rustc 1.32.0-nightly (6f93e93af 2018-11-14)

Crate graph from Cargo.lock:

"checksum bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "228047a76f468627ca71776ecdebd732a3423081fcf5125585bcd7c49886ce12"
"checksum cloudabi 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)" = "ddfc5b9aa5d4507acaf872de71051dfd0e309860e88966e1051e462a077aac4f"
"checksum fuchsia-zircon 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82"
"checksum fuchsia-zircon-sys 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7"
"checksum libc 0.2.43 (registry+https://github.com/rust-lang/crates.io-index)" = "76e3a3ef172f1a0b9a9ff0dd1491ae5e6c948b94479a3021819ba7d860c8645d"
"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
"checksum rand 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "de3f08319b5395bd19b70e73c4c465329495db02dafeb8ca711a20f1c2bd058c"
"checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a"
"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372"
"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db"
"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
"checksum rand_isaac 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2d6ecfe9ebf36acd47a49d150990b047a5f7db0a7236ee2414b7ff5cc1097c7b"
"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05"
"checksum rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3"
"checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a"
"checksum semver 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403"
"checksum semver-parser 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3"
"checksum winapi 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)" = "92c1eb33641e276cfa214a0522acad57be5c56b10cb348b3c5117db75f3ac4b0"
"checksum winapi-i686-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6"
"checksum winapi-x86_64-pc-windows-gnu 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f"
@dhardy
Copy link
Member

dhardy commented Nov 16, 2018

How many versions of rand_core are in your Cargo.lock?

Are default features enabled for one version of Rand but not the other?

I guess the solution is we should make a shim for Rand 0.5 on 0.6.

@koute
Copy link
Contributor Author

koute commented Nov 16, 2018

How many versions of rand_core are in your Cargo.lock?
Are default features enabled for one version of Rand but not the other?

rand_core 0.2.2 and 0.3.0 are used (they're not direct dependencies though), and the default features for rand 0.6 are disabled, and for 0.5 are enabled.

If both rand 0.6 and 0.5 has the default features enabled then everything compiles just fine.

@dhardy
Copy link
Member

dhardy commented Nov 17, 2018

rand_core 0.2.2 is just a shim around version 0.3, so that's fine.

The problem then is that rand_core::Error is a different type with std vs without. You need all versions of Rand used to have the same usage of std and alloc. At least, there's no point using Rand without std if it's also used with std somewhere in your dependency tree.

You might be able to work around this by directly depending on rand or rand_core with std (as an extra dependency somewhere) to force all versions used to use std.

Otherwise a shim for 0.5 around 0.6 will unify the feature flags.

@dvdplm
Copy link

dvdplm commented Nov 20, 2018

I saw something probably related to this where a rand_core 0.2.1 was already present and was used with rand 0.6. The error I saw was different though:

error[E0407]: method `seed_from_u64` is not a member of trait `SeedableRng`
   --> /Users/dvd/.cargo/registry/src/github.com-1ecc6299db9ec823/rand_isaac-0.1.0/src/isaac.rs:126:5
    |
126 | /     fn seed_from_u64(seed: u64) -> Self {
127 | |         IsaacRng(BlockRng::<IsaacCore>::seed_from_u64(seed))
128 | |     }
    | |_____^ not a member of trait `SeedableRng`

Adding a fake dependency on rand_core = 0.2.2 fixed the problem and once it the code compiles I could remove the rand_core dep. Maybe the constraints for rand_core should be made more stringent on the lower bound so that v0.2.1 is not used?

@koute
Copy link
Contributor Author

koute commented Nov 20, 2018

You need all versions of Rand used to have the same usage of std and alloc. At least, there's no point using Rand without std if it's also used with std somewhere in your dependency tree.

The main issue here is that this can easily break the compilation for the downstream users without any visible semver bump.

Imagine this scenario:

  1. I depend on crate foo 1.0.0 and on crate bar 1.0.0.
  2. The crate bar depends on rand 0.5, foo is #[no_std] and depends on rand 0.5 without the std feature. Both of these have rand as an internal dependency which isn't externally visible.
  3. foo updates its internal dependency on rand to 0.6 and is published as 1.0.1.
  4. I try to compile my crate and suddenly it breaks as cargo will automatically fetch foo 1.0.1 (which now has rand 0.6 without the default features) along with bar 1.0.0 (which still has rand 0.5).

This breaks the usual expectation that 1) dependency X shouldn't break the compilation of a completely unrelated dependency Y, and 2) that you can simultaneously have two versions of the same crate in your crate graph.

This wouldn't be a big of a deal for any random crate ('random' as in an arbitrarily picked crate which usually only have a few users on average, no pun intended 😃), but rand has 1883 other crates depending on it at this point in time.

@dhardy
Copy link
Member

dhardy commented Nov 20, 2018

Adding a fake dependency on rand_core = 0.2.2 fixed the problem

Probably cargo update -p rand_core would also fix it in this case.

Maybe the constraints for rand_core should be made more stringent on the lower bound so that v0.2.1 is not used?

As long as all versions of rand_core were 0.2 and < 0.2.2 there wouldn't be a problem — though the existence of rand_core 0.2.2 is to force everyone to upgrade, yes.

@koute if rand_core 0.2.2 requires std, it should force rand_core 0.3 to use std. The other way around it wouldn't, but since rand_core::Error is simply re-exported, it should be built with the same feature flags anyway. I don't understand how this happens. Cargo should only allow one configuration of rand_core 0.3, and rand_core 0.2 merely re-exports the same types.

In any case, maybe we can just push out a new release of rand 0.5 which requires rand_core 0.3? Hopefully that would fix the issue.

@pohl
Copy link

pohl commented Dec 10, 2018

I encountered this today in my side project, and it manifested as the same error that dvdplm mentioned above. The trick of temporarily adding rand_core = "0.2.2" worked. (I did first try cargo update -p rand_core, but that didn't work for me.)

@ghost
Copy link

ghost commented Dec 17, 2018

As far as I can tell, I'm running into the same issue. The problem manifests as my builds randomly breaking when I've made no changes. Very infuriating. It's happened twice now, but the error messages are different from the ones above.

Apologies for stretching the page, but I'm posting the full error log below so that people will be able to find this issue with a Google search.

   Compiling rand v0.6.1
error[E0277]: the trait bound `rand_hc::Hc128Rng: rand_core::SeedableRng` is not satisfied
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\std.rs:51:6
   |
51 | impl SeedableRng for StdRng {
   |      ^^^^^^^^^^^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Rng`

error[E0277]: the trait bound `rand_chacha::ChaChaRng: rand_core::SeedableRng` is not satisfied
   --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\deprecated.rs:141:6
    |
141 | impl SeedableRng for ChaChaRng {
    |      ^^^^^^^^^^^ the trait `rand_core::SeedableRng` is not implemented for `rand_chacha::ChaChaRng`

error[E0277]: the trait bound `rand_hc::Hc128Rng: rand_core::SeedableRng` is not satisfied
   --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\deprecated.rs:198:6
    |
198 | impl SeedableRng for Hc128Rng {
    |      ^^^^^^^^^^^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Rng`

error[E0277]: the trait bound `rand_xorshift::XorShiftRng: rand_core::SeedableRng` is not satisfied
   --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\deprecated.rs:239:6
    |
239 | impl SeedableRng for XorShiftRng {
    |      ^^^^^^^^^^^ the trait `rand_core::SeedableRng` is not implemented for `rand_xorshift::XorShiftRng`

error[E0277]: the trait bound `rand_hc::Hc128Rng: rand_core::SeedableRng` is not satisfied
   --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\deprecated.rs:279:6
    |
279 | impl SeedableRng for StdRng {
    |      ^^^^^^^^^^^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Rng`

error[E0277]: the trait bound `rand_hc::Hc128Core: rand_core::block::BlockRngCore` is not satisfied
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\thread.rs:75:5
   |
75 |     rng: *mut ReseedingRng<Hc128Core, EntropyRng>,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `rand_core::block::BlockRngCore` is not implemented for `rand_hc::Hc128Core`
   |
note: required by `rngs::adapter::reseeding::ReseedingRng`
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\adapter\reseeding.rs:88:1
   |
88 | / pub struct ReseedingRng<R, Rsdr>(BlockRng<ReseedingCore<R, Rsdr>>)
89 | | where R: BlockRngCore + SeedableRng,
90 | |       Rsdr: RngCore;
   | |____________________^

error[E0277]: the trait bound `rand_hc::Hc128Core: rand_core::SeedableRng` is not satisfied
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\thread.rs:75:5
   |
75 |     rng: *mut ReseedingRng<Hc128Core, EntropyRng>,
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Core`
   |
note: required by `rngs::adapter::reseeding::ReseedingRng`
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\adapter\reseeding.rs:88:1
   |
88 | / pub struct ReseedingRng<R, Rsdr>(BlockRng<ReseedingCore<R, Rsdr>>)
89 | | where R: BlockRngCore + SeedableRng,
90 | |       Rsdr: RngCore;
   | |____________________^

error[E0277]: the trait bound `rand_hc::Hc128Core: rand_core::block::BlockRngCore` is not satisfied
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\thread.rs:78:1
   |
78 | / thread_local!(
79 | |     static THREAD_RNG_KEY: UnsafeCell<ReseedingRng<Hc128Core, EntropyRng>> = {
80 | |         let mut entropy_source = EntropyRng::new();
81 | |         let r = Hc128Core::from_rng(&mut entropy_source).unwrap_or_else(|err|
...  |
87 | |     }
88 | | );
   | |__^ the trait `rand_core::block::BlockRngCore` is not implemented for `rand_hc::Hc128Core`
   |
note: required by `rngs::adapter::reseeding::ReseedingRng`
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\adapter\reseeding.rs:88:1
   |
88 | / pub struct ReseedingRng<R, Rsdr>(BlockRng<ReseedingCore<R, Rsdr>>)
89 | | where R: BlockRngCore + SeedableRng,
90 | |       Rsdr: RngCore;
   | |____________________^
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0277]: the trait bound `rand_hc::Hc128Core: rand_core::SeedableRng` is not satisfied
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\thread.rs:78:1
   |
78 | / thread_local!(
79 | |     static THREAD_RNG_KEY: UnsafeCell<ReseedingRng<Hc128Core, EntropyRng>> = {
80 | |         let mut entropy_source = EntropyRng::new();
81 | |         let r = Hc128Core::from_rng(&mut entropy_source).unwrap_or_else(|err|
...  |
87 | |     }
88 | | );
   | |__^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Core`
   |
note: required by `rngs::adapter::reseeding::ReseedingRng`
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\adapter\reseeding.rs:88:1
   |
88 | / pub struct ReseedingRng<R, Rsdr>(BlockRng<ReseedingCore<R, Rsdr>>)
89 | | where R: BlockRngCore + SeedableRng,
90 | |       Rsdr: RngCore;
   | |____________________^
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0277]: the trait bound `rand_hc::Hc128Core: rand_core::block::BlockRngCore` is not satisfied
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\thread.rs:78:1
   |
78 | / thread_local!(
79 | |     static THREAD_RNG_KEY: UnsafeCell<ReseedingRng<Hc128Core, EntropyRng>> = {
80 | |         let mut entropy_source = EntropyRng::new();
81 | |         let r = Hc128Core::from_rng(&mut entropy_source).unwrap_or_else(|err|
...  |
87 | |     }
88 | | );
   | |__^ the trait `rand_core::block::BlockRngCore` is not implemented for `rand_hc::Hc128Core`
   |
note: required by `rngs::adapter::reseeding::ReseedingRng`
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\adapter\reseeding.rs:88:1
   |
88 | / pub struct ReseedingRng<R, Rsdr>(BlockRng<ReseedingCore<R, Rsdr>>)
89 | | where R: BlockRngCore + SeedableRng,
90 | |       Rsdr: RngCore;
   | |____________________^
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0277]: the trait bound `rand_hc::Hc128Core: rand_core::SeedableRng` is not satisfied
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\thread.rs:78:1
   |
78 | / thread_local!(
79 | |     static THREAD_RNG_KEY: UnsafeCell<ReseedingRng<Hc128Core, EntropyRng>> = {
80 | |         let mut entropy_source = EntropyRng::new();
81 | |         let r = Hc128Core::from_rng(&mut entropy_source).unwrap_or_else(|err|
...  |
87 | |     }
88 | | );
   | |__^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Core`
   |
note: required by `rngs::adapter::reseeding::ReseedingRng`
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\adapter\reseeding.rs:88:1
   |
88 | / pub struct ReseedingRng<R, Rsdr>(BlockRng<ReseedingCore<R, Rsdr>>)
89 | | where R: BlockRngCore + SeedableRng,
90 | |       Rsdr: RngCore;
   | |____________________^
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0277]: the trait bound `rand_hc::Hc128Core: rand_core::block::BlockRngCore` is not satisfied
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\thread.rs:78:1
   |
78 | / thread_local!(
79 | |     static THREAD_RNG_KEY: UnsafeCell<ReseedingRng<Hc128Core, EntropyRng>> = {
80 | |         let mut entropy_source = EntropyRng::new();
81 | |         let r = Hc128Core::from_rng(&mut entropy_source).unwrap_or_else(|err|
...  |
87 | |     }
88 | | );
   | |__^ the trait `rand_core::block::BlockRngCore` is not implemented for `rand_hc::Hc128Core`
   |
note: required by `rngs::adapter::reseeding::ReseedingRng`
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\adapter\reseeding.rs:88:1
   |
88 | / pub struct ReseedingRng<R, Rsdr>(BlockRng<ReseedingCore<R, Rsdr>>)
89 | | where R: BlockRngCore + SeedableRng,
90 | |       Rsdr: RngCore;
   | |____________________^
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0277]: the trait bound `rand_hc::Hc128Core: rand_core::SeedableRng` is not satisfied
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\thread.rs:78:1
   |
78 | / thread_local!(
79 | |     static THREAD_RNG_KEY: UnsafeCell<ReseedingRng<Hc128Core, EntropyRng>> = {
80 | |         let mut entropy_source = EntropyRng::new();
81 | |         let r = Hc128Core::from_rng(&mut entropy_source).unwrap_or_else(|err|
...  |
87 | |     }
88 | | );
   | |__^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Core`
   |
note: required by `rngs::adapter::reseeding::ReseedingRng`
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\adapter\reseeding.rs:88:1
   |
88 | / pub struct ReseedingRng<R, Rsdr>(BlockRng<ReseedingCore<R, Rsdr>>)
89 | | where R: BlockRngCore + SeedableRng,
90 | |       Rsdr: RngCore;
   | |____________________^
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0277]: the trait bound `rand_hc::Hc128Core: rand_core::block::BlockRngCore` is not satisfied
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\thread.rs:78:1
   |
78 | / thread_local!(
79 | |     static THREAD_RNG_KEY: UnsafeCell<ReseedingRng<Hc128Core, EntropyRng>> = {
80 | |         let mut entropy_source = EntropyRng::new();
81 | |         let r = Hc128Core::from_rng(&mut entropy_source).unwrap_or_else(|err|
...  |
87 | |     }
88 | | );
   | |__^ the trait `rand_core::block::BlockRngCore` is not implemented for `rand_hc::Hc128Core`
   |
note: required by `rngs::adapter::reseeding::ReseedingRng`
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\adapter\reseeding.rs:88:1
   |
88 | / pub struct ReseedingRng<R, Rsdr>(BlockRng<ReseedingCore<R, Rsdr>>)
89 | | where R: BlockRngCore + SeedableRng,
90 | |       Rsdr: RngCore;
   | |____________________^
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0277]: the trait bound `rand_hc::Hc128Core: rand_core::SeedableRng` is not satisfied
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\thread.rs:78:1
   |
78 | / thread_local!(
79 | |     static THREAD_RNG_KEY: UnsafeCell<ReseedingRng<Hc128Core, EntropyRng>> = {
80 | |         let mut entropy_source = EntropyRng::new();
81 | |         let r = Hc128Core::from_rng(&mut entropy_source).unwrap_or_else(|err|
...  |
87 | |     }
88 | | );
   | |__^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Core`
   |
note: required by `rngs::adapter::reseeding::ReseedingRng`
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\adapter\reseeding.rs:88:1
   |
88 | / pub struct ReseedingRng<R, Rsdr>(BlockRng<ReseedingCore<R, Rsdr>>)
89 | | where R: BlockRngCore + SeedableRng,
90 | |       Rsdr: RngCore;
   | |____________________^
   = note: this error originates in a macro outside of the current crate (in Nightly builds, run with -Z external-macro-backtrace for more info)

error[E0277]: the trait bound `rand_hc::Hc128Rng: rand_core::SeedableRng` is not satisfied
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\std.rs:52:5
   |
52 |     type Seed = <Hc128Rng as SeedableRng>::Seed;
   |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Rng`

error[E0277]: the trait bound `rand_hc::Hc128Rng: rand_core::SeedableRng` is not satisfied
  --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\rngs\std.rs:54:5
   |
54 | /     fn from_seed(seed: Self::Seed) -> Self {
55 | |         StdRng(Hc128Rng::from_seed(seed))
56 | |     }
   | |_____^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Rng`

error[E0277]: the trait bound `rand_chacha::ChaChaRng: rand_core::SeedableRng` is not satisfied
   --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\deprecated.rs:142:5
    |
142 |     type Seed = <rand_chacha::ChaChaRng as SeedableRng>::Seed;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `rand_core::SeedableRng` is not implemented for `rand_chacha::ChaChaRng`

error[E0277]: the trait bound `rand_chacha::ChaChaRng: rand_core::SeedableRng` is not satisfied
   --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\deprecated.rs:144:5
    |
144 | /     fn from_seed(seed: Self::Seed) -> Self {
145 | |         ChaChaRng(rand_chacha::ChaChaRng::from_seed(seed))
146 | |     }
    | |_____^ the trait `rand_core::SeedableRng` is not implemented for `rand_chacha::ChaChaRng`

error[E0277]: the trait bound `rand_hc::Hc128Rng: rand_core::SeedableRng` is not satisfied
   --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\deprecated.rs:199:5
    |
199 |     type Seed = <rand_hc::Hc128Rng as SeedableRng>::Seed;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Rng`

error[E0277]: the trait bound `rand_hc::Hc128Rng: rand_core::SeedableRng` is not satisfied
   --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\deprecated.rs:201:5
    |
201 | /     fn from_seed(seed: Self::Seed) -> Self {
202 | |         Hc128Rng(rand_hc::Hc128Rng::from_seed(seed))
203 | |     }
    | |_____^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Rng`

error[E0277]: the trait bound `rand_xorshift::XorShiftRng: rand_core::SeedableRng` is not satisfied
   --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\deprecated.rs:240:5
    |
240 |     type Seed = <::rand_xorshift::XorShiftRng as SeedableRng>::Seed;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `rand_core::SeedableRng` is not implemented for `rand_xorshift::XorShiftRng`

error[E0277]: the trait bound `rand_xorshift::XorShiftRng: rand_core::SeedableRng` is not satisfied
   --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\deprecated.rs:242:5
    |
242 | /     fn from_seed(seed: Self::Seed) -> Self {
243 | |         XorShiftRng(::rand_xorshift::XorShiftRng::from_seed(seed))
244 | |     }
    | |_____^ the trait `rand_core::SeedableRng` is not implemented for `rand_xorshift::XorShiftRng`

error[E0277]: the trait bound `rand_hc::Hc128Rng: rand_core::SeedableRng` is not satisfied
   --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\deprecated.rs:280:5
    |
280 |     type Seed = <rngs::StdRng as SeedableRng>::Seed;
    |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Rng`

error[E0277]: the trait bound `rand_hc::Hc128Rng: rand_core::SeedableRng` is not satisfied
   --> C:\Users\flaradr_ljos\.cargo\registry\src\github.com-1ecc6299db9ec823\rand-0.6.1\src\deprecated.rs:282:5
    |
282 | /     fn from_seed(seed: Self::Seed) -> Self {
283 | |         StdRng(rngs::StdRng::from_seed(seed))
284 | |     }
    | |_____^ the trait `rand_core::SeedableRng` is not implemented for `rand_hc::Hc128Rng`

error: aborting due to 25 previous errors

For more information about this error, try `rustc --explain E0277`.
error: Could not compile `rand`.
warning: build failed, waiting for other jobs to finish...
error: build failed

Running cargo update fixed the problem, which among other things, bumped rand-core from 0.2.1 to 0.2.2.

I didn't think to save the dependency graph before running cargo update, but here's how it looks regarding rand packages right now.

"checksum rand 0.4.3 (registry+https://github.com/rust-lang/crates.io-index)" = "8356f47b32624fef5b3301c1be97e5944ecdd595409cc5da11d05f211db6cfbd"
"checksum rand 0.5.5 (registry+https://github.com/rust-lang/crates.io-index)" = "e464cd887e869cddcae8792a4ee31d23c7edd516700695608f5b98c67ee0131c"
"checksum rand 0.6.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ae9d223d52ae411a33cf7e54ec6034ec165df296ccd23533d671a28252b6f66a"
"checksum rand_chacha 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "771b009e3a508cb67e8823dda454aaa5368c7bc1c16829fb77d3e980440dd34a"
"checksum rand_core 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "1961a422c4d189dfb50ffa9320bf1f2a9bd54ecb92792fb9477f99a1045f3372"
"checksum rand_core 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0905b6b7079ec73b314d4c748701f6931eb79fd97c668caa3f1899b22b32c6db"
"checksum rand_hc 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "7b40677c7be09ae76218dc623efbf7b18e34bced3f38883af07bb75630a21bc4"
"checksum rand_isaac 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "ded997c9d5f13925be2a6fd7e66bf1872597f759fd9dd93513dd7e92e5a5ee08"
"checksum rand_pcg 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "086bd09a33c7044e56bb44d5bdde5a60e7f119a9e95b0775f545de759a32fe05"
"checksum rand_xorshift 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "effa3fcaa47e18db002bdde6060944b6d2f9cfd8db471c30e873448ad9187be3"

@dhardy
Copy link
Member

dhardy commented Dec 17, 2018

@aleksijuvani I think you are right — and yet I don't know of a good solution to this issue.

@Rua
Copy link

Rua commented Dec 21, 2018

Running cargo update fixed this issue for me as well, for future reference.

isislovecruft added a commit to isislovecruft/ed25519-dalek that referenced this issue Dec 22, 2018
@boustrophedon
Copy link

I had to run specifically cargo update -p rand_core:0.2.1 to fix this problem: when running cargo update rand_core I got an error telling me to specify which rand_core transitive dependency (0.3.0 or 0.2.1) to update. It's probable that running cargo update by itself would have done this, however.

boustrophedon added a commit to boustrophedon/taskerizer that referenced this issue Jan 2, 2019
Had to run `cargo update -p rand_core:0.2.1`,
see rust-random/rand#645
@hdevalence
Copy link

Hi there, just chiming in to report that this has suddenly become an issue in CI, e.g., https://travis-ci.org/dalek-cryptography/x25519-dalek/jobs/482946540

@dhardy
Copy link
Member

dhardy commented Jan 23, 2019

@hdevalence something is forcing rand-core to use the std feature. Maybe investigating the Cargo.lock file can find the culprit?

Optional, enabled-by-default features are highly problematic, as is relying on no dependency requesting some feature. We really need a better no_std mechanism.

@dhardy
Copy link
Member

dhardy commented Jan 23, 2019

Note: criterion depends on rand_core without mentioning features, which means this implicitly forces use of std. The problem is then that rand must use std if rand_core does, or you get this build error.

Hang tight, I am proposing a solution in a new issue... #702

malikolivier added a commit to aflak-vis/aflak that referenced this issue Mar 26, 2019
Choose version 0.7.1, as it depends on rand 0.5.
Currently, all aflak dependencies depend on rand 0.5.
We cannot afford to use the latest version of uuid (currently 0.7.3), as
it depends on rand 0.6, however rand 0.6 and 0.5 are not compatible [0].

[0] rust-random/rand#645
malikolivier added a commit to aflak-vis/aflak that referenced this issue Apr 2, 2019
Choose version 0.7.1, as it depends on rand 0.5.
Currently, all aflak dependencies depend on rand 0.5.
We cannot afford to use the latest version of uuid (currently 0.7.3), as
it depends on rand 0.6, however rand 0.6 and 0.5 are not compatible [0].

[0] rust-random/rand#645
evgenykuzyakov pushed a commit to near/nearcore that referenced this issue Nov 12, 2020
As the next step in #3506, and following up from #3542 and #3558, upgrade Parity Ethereum (now OpenEthereum) from [2.6.8] (Dec 2019) to [2.7.2] (Feb 2020), the last release in the 2.x series.

This harmonizes our dependency graph with upstream, fixing numerous build errors from the upgrade and eliminating multiple versions of the same crates. This concerns the [bn], [ethabi], [ethabi-contract], [ethabi-derive], [ethereum-types], [keccak-hash], [primitive-types], and [uint] crates as well as their transitive dependencies and their interdependencies.

The [near/bn] fork exists to upgrade [bn]'s [rand] dependency. That's necessary because of a particularly complex dependency issue (rust-random/rand#645) in old versions of rand. We will eliminate the fork going forward once upstream upgrades their dependency (I will open a pull request for them).

The upstream changelog for 2.7.2 is at: https://github.com/openethereum/openethereum/blob/v2.7.2/CHANGELOG.md

The upstream diff from 2.6.8 to 2.7.2 is at: openethereum/openethereum@v2.6.8...v2.7.2

[2.6.8]: https://github.com/openethereum/openethereum/releases/tag/v2.6.8
[2.7.2]: https://github.com/openethereum/openethereum/releases/tag/v2.7.2

[near/bn]: https://github.com/near/bn
[bn]: https://crates.io/crates/bn
[ethabi]: https://crates.io/crates/ethabi
[ethabi-contract]: https://crates.io/crates/ethabi-contract
[ethabi-derive]: https://crates.io/crates/ethabi-derive
[ethereum-types]: https://crates.io/crates/ethereum-types
[keccak-hash]: https://crates.io/crates/keccak-hash
[primitive-types]: https://crates.io/crates/primitive-types
[rand]: https://crates.io/crates/rand
[uint]: https://crates.io/crates/uint
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants