Skip to content

"All entropy sources failed" on wasm32-wasi #34

Closed

Description

@devsnek

A project i'm trying to build fails with All entropy sources failed (permanently unavailable); cause: OsRng: support for wasm32 requires emscripten, stdweb or wasm-bindgen (permanently unavailable), though getrandom says it supports __wasi_random_get

Activity

  1. newpavlov commented on Jun 14, 2019

    @newpavlov
    Member

    Looks like you are not building for WASI target (note: WASM is like CPU architecture and WASI is in a certain sense an operating system, so the first does not necessarily imply the second). Depending on that you use, enable stdweb or wasm-bindgen feature for getrandom crate. You can do it be adding this line to your project's Cargo.toml dependencies section:

    getrandom = { version = "*", features = ["wasm-bindgen"] }
  2. devsnek commented on Jun 14, 2019

    @devsnek
    Author

    i'm doing cargo build --target wasm32-unknown-wasi. (and I'm aware what WASI is to WASM)

  3. dhardy commented on Jun 14, 2019

    @dhardy
    Member

    As I said in the other issue, use the target wasm32-wasi (check the changelog).

  4. devsnek commented on Jun 14, 2019

    @devsnek
    Author

    updating to rustc beta and using wasm32-wasi produces the same error.

  5. newpavlov commented on Jun 14, 2019

    @newpavlov
    Member

    Hm, this is strange... I can't find from where this error comes. Search does not show any code in this and rand repository which produces it. What versions of getrandom/rand do you use? Have you tried to use getrandom directly?

    Note that getrandom is used only since rand v0.7 and rand_os v0.2, and IIRC earlier versions of those crates did not support WASI.

  6. devsnek commented on Jun 14, 2019

    @devsnek
    Author

    using rand 0.7.0-pre.1 worked.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions