clockworklabs/SpacetimeDB · error · anyhow::Error
wasm32-unknown-unknown target is not installed. Please…
Error message
wasm32-unknown-unknown target is not installed. Please install it.
What it means
Rust modules must compile to wasm32-unknown-unknown. The CLI probes by running `rustc --print target-libdir --target wasm32-unknown-unknown` and checking the printed libdir exists; if absent it auto-installs via `rustup target add wasm32-unknown-unknown`. Only when rustup is not found on PATH does it bail here, telling you to install the target yourself.
Solutions
- If you use rustup, make sure it is on PATH -- the CLI will then auto-add the target for you.
- Otherwise install the target explicitly: `rustup target add wasm32-unknown-unknown`.
- On rustup-less toolchains, install the wasm std for your system rustc via the distribution's package, or switch the image/CI to a rustup-based toolchain.
- In Dockerfiles, add the target in an earlier layer so it is cached.
Example fix
# before: Dockerfile with system rustc only RUN apt-get install -y rustc cargo # after RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y RUN $HOME/.cargo/bin/rustup target add wasm32-unknown-unknown
Defensive patterns
Strategy: validation
Validate before calling
# Fail fast before building if the wasm target is missing and rustup is absent
command -v rustup >/dev/null 2>&1 || \
rustc --print target-libdir --target wasm32-unknown-unknown >/dev/null 2>&1 || \
{ echo 'install wasm32-unknown-unknown (no rustup to auto-install it)' >&2; exit 1; }
spacetime build Prevention
- Add `rustup target add wasm32-unknown-unknown` to Dockerfiles/CI setup steps so it is cached before spacetime runs.
- Use rustup-managed toolchains in build images; system rustc without rustup cannot be auto-fixed by the CLI.
- After changing toolchains in an image, verify with `rustc --print target-libdir --target wasm32-unknown-unknown`.
When it happens
Trigger: `spacetime build` on a Rust module with a toolchain lacking the wasm32 target AND no rustup executable on PATH: distro-packaged rustc (apt/apay style), rustup-less CI images, or a PATH that hides rustup while rustc still resolves.
Common situations: Minimal Docker builder images with system rust; CI images with rustc from a package manager; corporate environments where rustup is blocked but a system toolchain exists.
Related errors
- {errno}
- Error checking for wasm32 target
- Error getting jwt
- Found disallowed print statement(s). These will not be…
- getrandom usage detected. It seems like either you or a…
AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20).
Data as JSON: /api/errors/fb412958701d0c3e.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/tasks/rust.rs:39
.chain((!build_debug).then_some("--release"))
.chain(args.iter().copied()),
)
}
pub(crate) fn build_rust(
project_path: &Path,
features: Option<&std::ffi::OsString>,
lint_dir: Option<&Path>,
build_debug: bool,
) -> anyhow::Result<PathBuf> {
// Make sure that we have the wasm target installed
if !has_wasm32_target() {
if has_rust_up() {
cmd!("rustup", "target", "add", "wasm32-unknown-unknown")
.run()
.context("Failed to install wasm32-unknown-unknown target with rustup")?;
} else {
anyhow::bail!("wasm32-unknown-unknown target is not installed. Please install it.");
}
}
if let Some(lint_dir) = lint_dir {
let mut err_count: u32 = 0;
let lint_dir = project_path.join(lint_dir);
for file in walkdir::WalkDir::new(lint_dir).into_iter() {
let file = file?;
let printable_path = file.path().to_str().ok_or(anyhow::anyhow!("path not utf-8"))?;
if file.file_type().is_file() && file.path().extension().is_some_and(|ext| ext == "rs") {
let file = fs::File::open(file.path())?;
for (idx, line) in io::BufReader::new(file).lines().enumerate() {
let line = line?;
let line_number = idx + 1;
for disallowed in &["println!", "print!", "eprintln!", "eprint!", "dbg!"] {
if line.contains(disallowed) {
if err_count == 0 {
eprintln!("\nDetected nonfunctional print statements:\n");View on GitHub (pinned to 6dee26c6ef)