# Failure to deploy canister when \`rand\` as dependency (Rust)

**URL:** <https://forum.dfinity.org/t/failure-to-deploy-canister-when-rand-as-dependency-rust/6686>\
**Category:** Developers\
**Created:** [August 24, 2021, 11:49pm UTC](https://forum.dfinity.org/t/failure-to-deploy-canister-when-rand-as-dependency-rust/6686 "2021-08-24T23:49:52Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![heldrida](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/heldrida/32/2302_2.png) [@heldrida](https://forum.dfinity.org/u/heldrida)\
**Post date:** [August 24, 2021, 11:49pm UTC](https://forum.dfinity.org/t/failure-to-deploy-canister-when-rand-as-dependency-rust/6686/1 "2021-08-24T23:49:52Z")

</div>

Hi,

The package `rand` has no support for `wasm32-unknown-unknown`, unless the `js` feature is enabled, i.e. add `getrandom = { version = "0.2", features = ["js"] }` to the dependencies.

```auto
[dependencies]
rand = "0.8"
getrandom = { version = "0.2", features = ["js"] }

```

When running:

```auto
dfx deploy canister_name

```

The following error is thrown:

```auto
The invocation to the wallet call forward method failed with the error: An error happened during the call: 5: Wasm module of canister xxxx-xxxx-xxxxx-xxxxxx is not valid: Wasm module has an invalid import section. Module imports function ' __wbindgen_object_drop_ref' from '__ wbindgen_placeholder__' that is not exported by the runtime.

```

The error is only thrown on `dfx cli`, where simply running the Rust cargo build does not throw an error.

```auto
cargo build --target wasm32-unknown-unknown --release --package xxxx

```

The `rand` package can be quite useful when mocking data.

Versions:  
cargo 1.54.0  
rustc 1.54.0  
rustup 1.24.3

References:  
[https://docs.rs/getrandom/0.2.3/getrandom/#webassembly-support](https://docs.rs/getrandom/0.2.3/getrandom/#webassembly-support)

> <https://github.com/rust-random/getrandom/issues/208>
>
> Hello! I’m a beginner just playing around with wasm-pack. While loading a crate …that uses \`rand\`, I try to run \`wasm-pack build --target web\` and get the following error:
> 
> \`\`\`
> error: target is not supported, for more information see: https://docs.rs/getrandom/#unsupported-targets
> --\> ~/.cargo/registry/src/github.com-1ecc6299db9ec823/getrandom-0.2.2/src/lib.rs:213:9
> |
> 213 | / compile\_error!("target is not supported, for more information see: \\
> 214 | | https://docs.rs/getrandom/#unsupported-targets");
> | |\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_\_^
> \`\`\`
> 
> It seems that neither \`--target web\` nor \`--target nodejs\`, which I’m trying to use (I’m trying to compile WASM both for web and Node).
> 
> Is there any chance that this project could support either target? Happy to help contribute if work is needed.
