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

rand 0.6.5 seems to be breaking the build #228

Closed
brycx opened this issue Jan 28, 2019 · 15 comments
Closed

rand 0.6.5 seems to be breaking the build #228

brycx opened this issue Jan 28, 2019 · 15 comments

Comments

@brycx
Copy link

brycx commented Jan 28, 2019

Not exactly sure if this belongs here or on rust-random/rand. Just tried to run cargo test with quickcheck = "0.8.0" in [dev-dependencies], without using the macros or importing them. This is what I get:

[...]

error[E0277]: the trait bound `rand_xorshift::XorShiftRng: rand_core::SeedableRng` is not satisfied
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/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
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/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
   --> /home/user/.cargo/registry/src/github.com-1ecc6299db9ec823/rand-0.6.5/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 34 previous errors

For more information about this error, try `rustc --explain E0277`.
error: Could not compile `rand`.
@BurntSushi
Copy link
Owner

Seems to be working fine for me:

$ cat Cargo.toml
[package]
name = "quickcheck-228"
version = "0.1.0"
edition = "2018"

[dev-dependencies]
quickcheck = "0.8.0"

$ cargo test
    Updating crates.io index
  Downloaded quickcheck v0.8.0
  Downloaded rand v0.6.5
  Downloaded regex-syntax v0.6.5
  Downloaded rand_jitter v0.1.0
   Compiling libc v0.2.48
   Compiling semver-parser v0.7.0
   Compiling memchr v2.1.3
   Compiling cfg-if v0.1.6
   Compiling autocfg v0.1.2
   Compiling ucd-util v0.1.3
   Compiling rand_core v0.4.0
   Compiling regex v1.1.0
   Compiling lazy_static v1.2.0
   Compiling quick-error v1.2.2
   Compiling utf8-ranges v1.0.2
   Compiling termcolor v1.0.4
   Compiling log v0.4.6
   Compiling humantime v1.2.0
   Compiling thread_local v0.3.6
   Compiling regex-syntax v0.6.5
   Compiling rand_core v0.3.1
   Compiling rand_jitter v0.1.0
   Compiling rand_chacha v0.1.1
   Compiling rand v0.6.5
   Compiling semver v0.9.0
   Compiling rand_hc v0.1.0
   Compiling rand_isaac v0.1.1
   Compiling rand_xorshift v0.1.1
   Compiling rustc_version v0.2.3
   Compiling rand_os v0.1.1
   Compiling atty v0.2.11
   Compiling rand_pcg v0.1.1
   Compiling aho-corasick v0.6.9
   Compiling env_logger v0.5.13
   Compiling quickcheck v0.8.0
   Compiling quickcheck-228 v0.1.0 (/tmp/quickcheck-228)
    Finished dev [unoptimized + debuginfo] target(s) in 9.63s
     Running target/debug/deps/quickcheck_228-d7675bb233b8040f

running 0 tests

test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out

I think you need to include more information about your build? The actual errors you're getting tell me that you're somehow not using compatible versions of rand in the same build, but your reproduction steps don't allow me to know for sure.

@brycx
Copy link
Author

brycx commented Jan 28, 2019

Huh, that's weird. I'm trying to build with latest stable and nightly Rust, edition = 2018. The full error log I've posted here https://pastebin.com/QM7jDrXp (those are when trying to build with stable).

These are my dependencies:

[dependencies]
rand_os = { version = "0.1.1", optional = true }
tiny-keccak = "1.4.2"
byteorder = { version = "1.2.7", default-features = false }
subtle = { version = "2", default-features = false }
clear_on_drop = "=0.2.3"

[dev-dependencies]
hex = "0.3.2"
serde_json = "1.0.33"
quickcheck = "0.8.0"

Let me know if you need anything else.

@BurntSushi
Copy link
Owner

Works just fine for me. Are you sure you aren't still depending on an older version of rand? Like I said in my original comment, that's what the errors are saying. For example, can you start a fresh project in the same way that I am and confirm the issue persists? If not, then it's likely you are still using an older version of rand somehow. Look at your Cargo.lock for example.

@brycx
Copy link
Author

brycx commented Jan 28, 2019

With a fresh library, this issue does not persist. I have checked the Cargo.lock and can't find a conflicting rand dep. The only thing I can think of is rand using a newer rand_core version compared to rand_os, but I can't confirm that with a fresh lib either.

I'll just have to see if rand_os gets updated and that fixes it. Thanks a lot for your help anyway!

@BurntSushi
Copy link
Owner

OK, then I'm going to close this for now. If you want to post the Cargo.lock of the project that is giving you problems, then I can look at it.

@brycx
Copy link
Author

brycx commented Jan 28, 2019

This is the Cargo.lock: https://pastebin.com/5qEyqzbz.

@BurntSushi
Copy link
Owner

I copied your Cargo.lock to my system and I was able to reproduce the error. I then ran cargo update:

$ cargo update
    Updating crates.io index
    Updating libc v0.2.44 -> v0.2.48
    Updating rand_core v0.3.0 -> v0.3.1
    Updating serde v1.0.83 -> v1.0.85
    Updating serde_json v1.0.33 -> v1.0.37

And now things work.

Sigh. It looks like the rand maintainers used the semver trick to release a 0.4 version of rand_core which is specifically incompatible with rand_core 0.3.0 but is compatible with rand_core 0.3.1 (again, because this is how the semver trick works). Your project is somehow using both rand_core 0.3.0 and rand_core 0.4.0 simultaneously, which are incompatible with one another. To me, this means someone messed up somewhere and hasn't declared minimal dependency versions somewhere, but I don't know for sure and don't have the patience to look into it.

@brycx
Copy link
Author

brycx commented Jan 28, 2019

I didn't know about cargo update, that's neat. I see, this clears things up a lot. Again, thanks a lot for the help!

@dhardy
Copy link

dhardy commented Jan 28, 2019

Yep, @BurntSushi is on the ball.

To me, this means someone messed up somewhere and hasn't declared minimal dependency versions somewhere, but I don't know for sure and don't have the patience to look into it.

Is there a way to avoid this? Because rand_core 0.3.1 can't be published until after 0.4.0 is released. And after that, is there a way to force all 0.3.0 users to upgrade?

@BurntSushi
Copy link
Owner

@dhardy I don't know. :-( It was just a guess. I've never used the semver trick myself, so I'm not completely intimate with how it works and its ramifications. Maybe it means bumping other dependencies like rand_chacha which declare compatibility with 0.3.0 and 0.3.1 but not 0.4? Not sure.

@WiSaGaN
Copy link

WiSaGaN commented Feb 22, 2019

Searching rand 0.6.5 fails the build lands me here.
I used

cargo update -p rand_core:0.3.0

to fix the issue.
Thought I just comment here in case this helps others who are looking for a minimal fix.

@BurntSushi
Copy link
Owner

BurntSushi commented Feb 22, 2019

@WiSaGaN That command is explicitly setting rand_core to an older version. You should probably figure out how to upgrade to 0.4.0. just run cargo uodate. I'm other words, I don't think your solution is one that everyone should generally use.

@WiSaGaN
Copy link

WiSaGaN commented Feb 22, 2019

@BurntSushi I thought the command is to update all occurrences of rand_core 0.3.0 which I believe it is the version not compatible with what's used in rand 0.6.5?

@BurntSushi
Copy link
Owner

Oh I see, I misread that as seeing a precisely option, but that requires the precise flag. Sorry!

@WiSaGaN
Copy link

WiSaGaN commented Feb 22, 2019

Nevermind! You are right it is not recommended to everyone; it is only intended for those who want minimal changes to fix this.

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

4 participants