Search code examples
rustwebassemblyrust-cargo

Rust can't find 'crate' for 'std'


I'm trying to get a .wasm file via RUSTFLAGS='-C link-arg=-s' cargo build --release --target wasm32-unknown-unknown but get the error:

error[E0463]: can't find crate for `std`

When i type rustup target add wasm32-unknown-unknown i get:

info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date

I installed Rust and Rustup separate via chocolatey.

  • rustc 1.58.0
  • rustup 1.24.3
  • info: The currently active rustc version is rustc 1.60.0-nightly (5e57faa78 2022-01-19)

Solution

  • You need to add the wasm32-unknown-unknown target for the nightly toolchain if that's what you are using:

    rustup target add --toolchain nightly wasm32-unknown-unknown