Skip to content

“use of undeclared crate or module imp” on getrandom-0.2.8 when building for wasm32-unknown-unknown #866

@franksanchez112595

Description

@franksanchez112595

I cloned cw20-base and tried to cargo build-bpf but failed.

This is Cargo.toml

[lib]
crate-type = ["cdylib", "rlib"]

[features]
backtraces = ["cosmwasm-std/backtraces"]
# use library feature to disable all instantiate/execute/query exports
library = []

[dependencies]
cosmwasm-schema = "1.2.3"
cosmwasm-std = "1.2.3"
cw-storage-plus = "1.0.1"
cw-utils = "1.0.1"
cw2 = "1.0.1"
cw20 = "1.0.1"
schemars = "0.8.12"
semver = "1.0.17"
serde = { version = "1.0.159", default-features = false, features = ["derive"] }
thiserror = "1.0.40"

[dev-dependencies]
cw-multi-test = "0.16.1"

I got error like this

error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
   --> src/lib.rs:268:9
    |
268 | /         compile_error!("target is not supported, for more information see: \
269 | |                         https://docs.rs/getrandom/#unsupported-targets");
    | |________________________________________________________________________^

error[E0433]: failed to resolve: use of undeclared crate or module `imp`
   --> src/lib.rs:290:5
    |
290 |     imp::getrandom_inner(dest)
    |     ^^^ use of undeclared crate or module `imp`

For more information about this error, try `rustc --explain E0433`.
error: could not compile `getrandom` due to 2 previous errors
warning: build failed, waiting for other jobs to finish...

Unsupport targets doesn't work, too.
I added the getrandom dependency mannually getrandom = { version = "0.2", features = ["js"] } in Cargo.toml file but its version doesn't change into 0.2.8 in Cargo.lock and the error still happened.

Is there anyone who can help me urgently?
I pulled tons of hairs to solve it for some days.

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