我每次运行时都会收到此错误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)`
Run Code Online (Sandbox Code Playgroud)
Cargo.toml看起来像这样:
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)`
Run Code Online (Sandbox Code Playgroud)
小智 9
这个错误是因为没有0.9.0可用的版本而导致的。将其更新为0.8.0. Cargo.toml 应该看起来像这样。
[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"
Run Code Online (Sandbox Code Playgroud)
出现此类错误的另一个可能原因是您的编译器已过时,并且新版本的库针对的是新编译器。使用 更新您的工具链rustup update。
我有一个使用 clap 4.2 的项目,但它拒绝在另一台计算机上编译,并出现这样的错误。
| 归档时间: |
|
| 查看次数: |
7229 次 |
| 最近记录: |