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`.

相关推荐
你好,帅哥19 分钟前
openssl ,msys2 ,交叉编译
linux·运维·服务器
消失的旧时光-194324 分钟前
Spring Boot 工程化进阶:统一返回 + 全局异常 + AOP 通用工具包
java·spring boot·后端·aop·自定义注解
NE_STOP33 分钟前
Redis--发布订阅命令和Redis事务
java
Wect35 分钟前
React 性能优化精讲
前端·react.js·性能优化
PAC_3Dame37 分钟前
记一次真实的线上OOM
java
SunnyDays10111 小时前
如何在Java中将Word文档转换为图像(JPEG、PNG或SVG)
java
追风筝的人er1 小时前
SpringBoot+Vue3 企业考勤如何处理法定假期?节假日方案、调休补班与工作日判断链路拆解
前端·vue.js·后端
Web极客码1 小时前
2026年Linux VPS安全加固清单:SSH、防火墙与审计就绪配置
运维·服务器·数据库
Lumos_7771 小时前
Linux -- 线程
java·jvm·算法
无敌的黑星星1 小时前
Java8 CompletableFuture 实战指南
linux·前端·python