Skip to content
Latchkey

rustup "the wasm32-unknown-unknown target may not be installed" in CI

cargo tried to compile for wasm32-unknown-unknown but the runner's toolchain has no std for that target. rustup only ships the host target by default, so you must add the wasm target explicitly.

What this error means

A wasm build fails with "error[E0463]: can't find crate for std" and the note "the wasm32-unknown-unknown target may not be installed". Host builds compile fine.

cargo
error[E0463]: can't find crate for `std`
  |
  = note: the `wasm32-unknown-unknown` target may not be installed
  = help: consider downloading the target with `rustup target add wasm32-unknown-unknown`

Common causes

The wasm target was never added to the toolchain

rustup installs only the host target by default. Without rustup target add wasm32-unknown-unknown, there is no precompiled std for wasm, so the crate graph cannot link.

A pinned toolchain that lacks the target

A rust-toolchain.toml selects a channel, but CI added the target to a different toolchain than the one the build actually uses.

How to fix it

Add the wasm target before building

  1. Run rustup target add wasm32-unknown-unknown in a step before the build.
  2. Build with --target wasm32-unknown-unknown so the added target is used.
  3. If a toolchain is pinned, add the target to that same toolchain.
Terminal
rustup target add wasm32-unknown-unknown
cargo build --release --target wasm32-unknown-unknown

Declare the target in the toolchain action

The setup action can install the target so it always matches the active toolchain.

.github/workflows/ci.yml
- uses: dtolnay/rust-toolchain@stable
  with:
    targets: wasm32-unknown-unknown

How to prevent it

  • Add the wasm target in the same step or action that selects the toolchain.
  • List required targets in your toolchain setup action so they cannot drift.
  • Build with an explicit --target so the intended target is unambiguous.

Related guides

Tired of flaky CI? Latchkey auto-heals failed jobs and retries them for you. Start free →