You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
cargo check --target wasm32-unknown-unknown
error: the wasm*-unknown-unknown targets are not supported by default, you may need to enable the "js" feature. For more information see: https://docs.rs/getrandom/#webassembly-support
--> /home/casatta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.12/src/lib.rs:291:9
|
291 | / compile_error!("the wasm*-unknown-unknown targets are not supported by \
292 | | default, you may need to enable the \"js\" feature. \
293 | | For more information see: \
294 | | https://docs.rs/getrandom/#webassembly-support");
| |________________________________________________________________________^
error[E0433]: failed to resolve: use of undeclared crate or module `imp`
--> /home/casatta/.cargo/registry/src/index.crates.io-6f17d22bba15001f/getrandom-0.2.12/src/lib.rs:347:9
|
347 | 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` (lib) due to 2 previous errors
warning: build failed, waiting for other jobs to finish...
Ohh, I see. It's a dev-dependency because this avoids making it a dependency downstream. We don't want to force wasm users to have rand on. What we want to say is, if the user has rand on, and they are on WASM, then they should have the rand/js feature on ... but Cargo has no way to say this.
Activity
apoelstra commentedon Jan 22, 2024
In rust-secp we have the following code in our Cargo.toml
I guess we need to copy that here. (Though I'm surprised that us having a rust-secp dependency here is insufficient.)
RCasatta commentedon Jan 23, 2024
The rust-secp code seems it's there also in rust-secp-zkp https://github.com/BlockstreamResearch/rust-secp256k1-zkp/blob/master/Cargo.toml (it puzzles me it's a DEV-dependencies but anyway).
Not sure if some deps is taking it without the js feature?
If I add
to rust-elements the build succeeds but I am not sure it's the right way to do it
apoelstra commentedon Jan 23, 2024
Ohh, I see. It's a dev-dependency because this avoids making it a dependency downstream. We don't want to force wasm users to have
randon. What we want to say is, if the user hasrandon, and they are on WASM, then they should have therand/jsfeature on ... but Cargo has no way to say this.So what you're doing is the right thing, AFAICT.