Wasm module iinvalid import error in Rust canister deployment

I’m deploying a Rust-based canister on the IC using dfx deploy, but I’m getting the following error when trying to install the Wasm module:

Error: Failed while trying to deploy canisters.
Caused by: Failed while trying to install all canisters.
Caused by: Failed to install wasm module to canister ‘mugc-sense-voice-backend’.
Caused by: Failed during wasm installation call
Caused by: The replica returned a rejection error: reject code CanisterError, reject message Error from Canister bd3sg-teaaa-aaaaa-qaaba-cai: Canister’s Wasm module is not valid: Wasm module has an invalid import section. Module imports function ‘__wbg_crypto_ed58b8e10a292839’ from ‘wbindgen_placeholder’ that is not exported by the runtime…
This is likely an error with the compiler/CDK toolchain being used to build the canister. Please report the error to IC devs on the forum: and include which language/CDK was used to create the canister., error code None

Here is my Environment:
Rust version: rustc 1.84.1 (e71f9a9a9 2025-01-27)
DFX version: dfx 0.24.3
CDK version:
├── ic-cdk v0.16.0
│ ├── ic-cdk-macros v0.16.0 (proc-macro)
├── ic-cdk-macros v0.17.1 (proc-macro)
├── ic-cdk-timers v0.10.0
│ ├── ic-cdk v0.16.0 (*)

Cargo.toml:
[dependencies]
candid = “0.10”
ic-cdk = “0.16”
ic-cdk-timers = “0.10”
ic-cdk-macros = “0.17.1”

ndarray = “0.15”
ndarray-rand = “0.15” # Random number generation for tensors
linfa = “0.4” # General machine learning framework
linfa-trees = “0.7.1” # For potential model handling
wasm-bindgen = “0.2” # For WebAssembly
serde = { version = “1.0”, features = [“derive”] } # For JSON serialization
serde_json = “1.0” # For handling JSON
rand = “0.8” # Random number generation
getrandom = { version = “0.2”, features = [“js”] }
rand_distr = “0.4”

[profile.release]
panic = “abort”

If you have any insights, free feel reach out, thanks in advance.

1 Like

Problem resolved, thanks Severin.

1 Like