How can I resolve not found cargo wasm error?

255 Views Asked by At

when build contract with RUSTFLAGS='-C link-arg=-s' cargo wasm, it shows bellow error.

1

After installed wasm-pack with cargo install, it still shows this error. How can I fix it?

2

There are 2 best solutions below

0
Leonard Lepadatu On

Try to install cargo-wasm:

 $ cargo install cargo-wasm

then

$ cargo --list

to see if was correctly installed

then setup your project

$ cargo setup

Cheers!

0
kmchmk On

Don't install cargo-wasm package for this. Usually we don't use cargo-wasm package for cargo wasm. cargo wasm is an alias for wasm = "build --release --lib --target wasm32-unknown-unknown" usually. So do the following.

Create a folder named .cargo and a .cargo/config file. Then add the following content.

[alias]
wasm = "build --release --lib --target wasm32-unknown-unknown"
wasm-debug = "build --lib --target wasm32-unknown-unknown"

Then the command cargo wasm or RUSTFLAGS='-C link-arg=-s' cargo wasm should work as expected.