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

相关推荐

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

    2024-06-16 06:50:03       10 阅读
  2. mace | ubuntu编译mace

    2024-06-16 06:50:03       14 阅读
  3. 代码编译出错可能的原因

    2024-06-16 06:50:03       65 阅读
  4. macOS编译ckb-next

    2024-06-16 06:50:03       39 阅读

最近更新

  1. TCP协议是安全的吗?

    2024-06-16 06:50:03       16 阅读
  2. 阿里云服务器执行yum,一直下载docker-ce-stable失败

    2024-06-16 06:50:03       16 阅读
  3. 【Python教程】压缩PDF文件大小

    2024-06-16 06:50:03       15 阅读
  4. 通过文章id递归查询所有评论(xml)

    2024-06-16 06:50:03       18 阅读

热门阅读

  1. 深入浅出Spring Boot自动装配:让开发更轻松

    2024-06-16 06:50:03       9 阅读
  2. Qt 槽函数重载时通过函数指针绑定

    2024-06-16 06:50:03       9 阅读
  3. 常用的Linux、python命令

    2024-06-16 06:50:03       5 阅读
  4. 【学习笔记】MySQL(Ⅲ)

    2024-06-16 06:50:03       7 阅读
  5. 【手机】米10替换基带

    2024-06-16 06:50:03       6 阅读
  6. Cheat Engine.exe修改植物大战僵尸阳光与冷却

    2024-06-16 06:50:03       8 阅读
  7. 模拟题1(考虑周全以及情况较多)

    2024-06-16 06:50:03       6 阅读
  8. 深入理解Python闭包:概念、应用与示例

    2024-06-16 06:50:03       10 阅读
  9. 目录深度探索

    2024-06-16 06:50:03       6 阅读
  10. Leetcode.2601 质数减法运算

    2024-06-16 06:50:03       8 阅读