Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
franksanchez112595 opened this issue Apr 5, 2023 · 1 comment

Comments

@franksanchez112595
Copy link

franksanchez112595 commented Apr 5, 2023

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.

@webmaster128
Copy link
Member

webmaster128 commented Nov 13, 2023

I don't know anything about cargo build-bpf and we don't support that. The wasm build command that is working is: cargo build --release --lib --target wasm32-unknown-unknown. The --lib part ensures not examples, tests etc. are compiled to Wasm. Maybe that helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants