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

相关推荐
We་ct5 分钟前
LeetCode 4. 寻找两个正序数组的中位数:二分优化思路详解
前端·数据结构·算法·leetcode·typescript·二分
于先生吖9 分钟前
国际语言适配拼车系统 JAVA 后端源码 + 同城顺风车功能全解析
java·开发语言
H@Z*rTE|i9 分钟前
vue首屏加载优化
前端·javascript·vue.js
FreeBuf_10 分钟前
新型开源供应链攻击:虚假 npm 安装日志暗藏 RAT 木马
前端·npm·开源
Irene199111 分钟前
v-model 的本质,defineModel() 是 Vue 3.4 的重大改进
前端·javascript·html5
czlczl2002092518 分钟前
KRaft原理
java·zookeeper
vvw&21 分钟前
如何在 Linux 中安装和使用 nftables
linux·运维·服务器·ubuntu
桌面运维家25 分钟前
KVM虚拟机:Neutron网络故障诊断与修复实战
服务器·网络·php
zl_dfq27 分钟前
计算机网络 之 【http协议】(简易HTTP服务器实现逻辑)
服务器·计算机网络·http
EF@蛐蛐堂38 分钟前
【vue】Vite 生态 5 个 “新玩具“
前端·javascript·vue.js