-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
getrandom 0.2 is a hard dependency of ic-vetkeys package. When building a package with the dependency
ic-vetkeys = { git = "https://github.com/dfinity/vetkeys" }it fails with the following error:
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
--> ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.2.16/src/lib.rs:346:9
|
346 | / compile_error!("the wasm*-unknown-unknown targets are not supported by \
347 | | default, you may need to enable the \"js\" feature. \
348 | | For more information see: \
349 | | https://docs.rs/getrandom/#webassembly-support");
| |________________________________________________________________________^
error[E0433]: failed to resolve: use of unresolved module or unlinked crate `imp`
--> ~/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/getrandom-0.2.16/src/lib.rs:402:9
|
402 | imp::getrandom_inner(dest)?;
| ^^^ use of unresolved module or unlinked crate `imp`
|
= help: if you wanted to use a crate named `imp`, use `cargo add imp` to add it to your `Cargo.toml`
Workaround
for anyone stumbling upon, the workaround looks like:
Cargo.toml
[dependencies]
getrandom_03 = { version = "0.3.3", package = "getrandom" }
getrandom_02 = { version = "0.2", package = "getrandom", features = ["custom"] }lib.rs
#[unsafe(no_mangle)]
unsafe extern "Rust" fn __getrandom_v03_custom(
_dest: *mut u8,
_len: usize,
) -> Result<(), getrandom_03::Error> {
Err(getrandom_03::Error::UNSUPPORTED)
}
pub fn always_fail_02(_buf: &mut [u8]) -> Result<(), getrandom_02::Error> {
Err(getrandom_02::Error::UNSUPPORTED)
}
getrandom_02::register_custom_getrandom!(always_fail_02);Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels