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

相关推荐
悟能不能悟2 分钟前
JAVA 中dao层的实体应该属于哪个层次VO,还是DTO,或者其他
java·开发语言
醇氧3 分钟前
在 Spring Service 中使用 private final Gson gson = new Gson(); 是否安全?
java·安全·spring
二狗哈6 分钟前
Cesium快速入门17:与entity和primitive交互
开发语言·前端·javascript·3d·webgl·cesium·地图可视化
chenyuhao20246 分钟前
Linux系统编程:Ext文件系统
linux·运维·服务器·开发语言·网络·c++·后端
xingzhemengyou17 分钟前
python datetime模块使用
前端·python
CodeAmaz8 分钟前
InnoDB的MVCC机制
java·数据库·mvcc
KingRumn13 分钟前
Linux进程间通信之内存映射
linux·运维·服务器
CoderYanger24 分钟前
贪心算法:4.摆动序列
java·算法·leetcode·贪心算法·1024程序员节
默 语35 分钟前
Spring-AI vs LangChain4J:Java生态的AI框架选型指南
java·人工智能·spring·ai·langchain·langchain4j·spring-ai
GISer_Jing36 分钟前
AI驱动营销增长:7大核心场景与前端实现
前端·javascript·人工智能