mac编译dbgen出错rand::rngs::OsRng

error[E0432]: unresolved import `rand::rngs::OsRng`

--> /Users/lanyuan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dbgen-0.8.0/src/cli.rs:19:27

|

19 | rngs::{mock::StepRng, OsRng},

| ^^^^^ no `OsRng` in `rngs`

|

note: found an item that was configured out

--> /Users/lanyuan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rand-0.8.5/src/rngs/mod.rs:119:50

|

119 | #[cfg(feature = "getrandom")] pub use rand_core::OsRng;

| ^^^^^

= note: the item is gated behind the `getrandom` feature

error[E0432]: unresolved import `rand::rngs::OsRng`

--> /Users/lanyuan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dbgen-0.8.0/src/schemagen_cli.rs:5:12

|

5 | use rand::{rngs::OsRng, seq::SliceRandom, Rng, RngCore, SeedableRng};

| ^^^^^^^^^^^ no `OsRng` in `rngs`

|

note: found an item that was configured out

--> /Users/lanyuan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rand-0.8.5/src/rngs/mod.rs:119:50

|

119 | #[cfg(feature = "getrandom")] pub use rand_core::OsRng;

| ^^^^^

= note: the item is gated behind the `getrandom` feature

分析:

网上和kimi提示添加依赖到Cargo.toml:

dependencies

rand = { version = "0.8", features = ["getrandom"] }

根据编译路径,找到/Users/lanyuan/.cargo/registry/src/index.crates.io-6f17d22bba15001f/dbgen-0.8.0,打开Cargo.toml,长这样:

dependencies.rand

version = "0.8.5"

default-features = false

修改false为true解决。

语法差别是rust 1.49 2018版本同rust 1.79的区别。

For more information about this error, try `rustc --explain E0432`.

error: could not compile `dbgen` (lib) due to 2 previous errors

error: failed to compile `dbgen v0.8.0`, intermediate artifacts can be found at `/var/folders/qn/sls3xhws4218snv410vq6x380000gn/T/cargo-installNSCX7t`.

相关推荐
EF@蛐蛐堂8 分钟前
【vue3】v-model 的 “新玩法“
前端·javascript·vue.js
百锦再12 分钟前
.NET 的 WebApi 项目必要可配置项都有哪些?
java·开发语言·c#·.net·core·net
两个月菜鸟18 分钟前
vue+微信小程序 五角星
前端·vue.js·微信小程序
耳东哇22 分钟前
spring ai-openai-vl模型应用qwen-vl\gpt-文字识别-java
java·人工智能·spring
獭.獭.24 分钟前
Linux -- 文件【下】
linux·服务器·文件系统·软硬链接·inode·ext2
花开富贵ii1 小时前
代码随想录算法训练营四十三天|图论part01
java·数据结构·算法·深度优先·图论
GISer_Jing1 小时前
React手撕组件和Hooks总结
前端·react.js·前端框架
破刺不会编程2 小时前
socket编程UDP
linux·运维·服务器·网络·c++·网络协议·udp
布朗克1683 小时前
Java 10 新特性及具体应用
java·开发语言·新特性·java10
ZZHow10245 小时前
JavaWeb开发_Day05
java·笔记·web