rustrust-cargo

Failed to select a version for the requirement `rand = "^0.9.0"`


I am getting this error every time while running cargo build:

error: failed to select a version for the requirement `rand = "^0.9.0"`
candidate versions found which didn't match: 0.8.5, 0.8.4, 0.8.3, ...
location searched: crates.io index
required by package `guessing_game v0.1.0 (D:\Adwait\Rust\project\guessing_game)`

Cargo.toml looks like this:

[package]
name = "guessing_game"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
rand = "0.9.0"

Solution

  • This error is caused because there is no version 0.9.0 available. Update it to 0.8.0. Cargo.toml should look like this.

    [package]
    name = "guessing_game"
    version = "0.1.0"
    edition = "2021"
    
    # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
    
    [dependencies]
    rand = "0.8.0"