【问题标题】:Failed to select a version for the requirement `rand = "^0.9.0"`Failed to select a version for the requirement `rand = \"^0.9.0\"`
【发布时间】:2022-12-27 04:16:03
【问题描述】:
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)`

I am getting this error every time while running cargo build. 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"

【问题讨论】:

  • I could know it now. As I am a beginner in rust.

标签: rust rust-cargo


【解决方案1】:

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"

【讨论】:

    【解决方案2】:

    I experienced this myself, I believe the confusion is stemming from the tutorial on Rust mentioning 0.9.0 as an example to understand upgrading Rust crates.

    I'm not sure why they chose that example, since it doesn't exist. Would be a better idea to do 0.7.x being upgraded to 0.8.0 if you're new to Rust and want to play around with upgrading Rust crates.

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-12-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-12-02
      • 2023-02-01
      • 2016-08-30
      • 2022-11-16
      相关资源
      最近更新 更多