spacetime publish fails with missing wasm32-unknown-unknown target error on Windows 11
Description:
I'm running Windows 11 and have installed SpacetimeDB using the official PowerShell installation guide. I also have the SpacetimeDB server running in a Docker container. My intention is to use the Spacetime CLI via PowerShell, while the database itself runs in Docker.
I followed the Rust quickstart guide, and everything worked fine until I ran the publish command:
spacetime publish --project-path server quickstart-chat
This is the output I received:
info: component 'rust-std' for target 'wasm32-unknown-unknown' is up to date
Compiling version_check v0.9.5
Compiling proc-macro2 v1.0.94
Compiling unicode-ident v1.0.18
Compiling typenum v1.18.0
Compiling cfg-if v1.0.0
Compiling autocfg v1.4.0
Compiling zerocopy v0.8.24
Compiling either v1.15.0
Compiling shlex v1.3.0
Compiling thiserror v1.0.69
Compiling nohash-hasher v0.2.0
error[E0463]: can't find crate for `core`
|
= note: the `wasm32-unknown-unknown` target may not be installed
= help: consider downloading the target with `rustup target add wasm32-unknown-unknown`
For more information about this error, try `rustc --explain E0463`.
error: could not compile `cfg-if` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
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`
error: could not compile `either` (lib) due to 1 previous error
error: could not compile `nohash-hasher` (lib) due to 1 previous error
Error: command ["cargo", "build", "--config=net.git-fetch-with-cli=true", "--target=wasm32-unknown-unknown", "--release", "--message-format=json-render-diagnostics"] exited with code 101
To investigate further, I tried compiling manually with:
cargo build --target wasm32-unknown-unknown --release
This gave similar errors:
Compiling cfg-if v1.0.0
Compiling nohash-hasher v0.2.0
Compiling either v1.15.0
Compiling typenum v1.18.0
Compiling zerocopy v0.8.24
Compiling bitflags v2.9.0
Compiling num-traits v0.2.19
Compiling spacetimedb-primitives v1.0.1
Compiling syn v2.0.100
Compiling anyhow v1.0.98
Compiling serde v1.0.219
Compiling convert_case v0.4.0
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`
For more information about this error, try `rustc --explain E0463`.
error[E0463]: can't find crate for `core`
|
= note: the `wasm32-unknown-unknown` target may not be installed
= help: consider downloading the target with `rustup target add wasm32-unknown-unknown`
error: could not compile `nohash-hasher` (lib) due to 1 previous error
warning: build failed, waiting for other jobs to finish...
error: could not compile `cfg-if` (lib) due to 1 previous error
error: could not compile `either` (lib) due to 1 previous error
error: could not compile `bitflags` (lib) due to 1 previous error
error: could not compile `zerocopy` (lib) due to 1 previous error
error: could not compile `typenum` (lib) due to 1 previous error
error: could not compile `num-traits` (lib) due to 1 previous error
error: could not compile `serde` (lib) due to 1 previous error
It seems like the wasm32-unknown-unknown target is either missing or not functioning correctly, even though the CLI reports it's up to date.
Any guidance on how to resolve this would be greatly appreciated.
One more thing
rustup show
outputs
Default host: x86_64-pc-windows-msvc
rustup home: C:\Users\[USER]\.rustup
installed targets for active toolchain
--------------------------------------
wasm32-unknown-unknown
x86_64-pc-windows-msvc
active toolchain
----------------
stable-x86_64-pc-windows-msvc (default)
rustc 1.85.1 (4eb161250 2025-03-15)
I responded in discord but I'll post this here as well for the Github users:
I would try a few obvious things first:
- Restart powershell
- Restart your windows machine
If it still doesn't work then try:
rustup update
rustup target add wasm32-unknown-unknown
Rustup was stuck in a corrupted state for reasons unknown. I resolved it with the following steps:
rustup uninstall stable
rustup install stable
rustup target add wasm32-unknown-unknown
Posting this in case it helps others facing a similar issue.