{"record":{"id":"43e3ea1cd08d6974","repo":"clockworklabs/SpacetimeDB","slug":"error-checking-for-wasm32-target-err","errorCode":null,"errorMessage":"Error checking for wasm32 target: {err}","messagePattern":"Error checking for wasm32 target: (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"crates/cli/src/detect.rs","lineNumber":51,"sourceCode":"            false\n        }\n    }\n}\n\n/// Check if the target `wasm32-unknown-unknown` is installed.\npub(crate) fn has_wasm32_target() -> bool {\n    let result = || {\n        let path = cmd!(\n            \"rustc\",\n            \"--print\",\n            \"target-libdir\",\n            \"--target\",\n            \"wasm32-unknown-unknown\"\n        )\n        .read()?;\n        Path::new(path.trim())\n            .try_exists()\n            .map_err(|err: io::Error| anyhow::anyhow!(err))\n    };\n\n    result().unwrap_or_else(|err| {\n        eprintln!(\"Error checking for wasm32 target: {err}\");\n        false\n    })\n}\n\n/// Check if a given `PackageManager` executable is available on `PATH`.\n///\n/// On Windows, npm/pnpm/yarn are `.cmd` shims while bun is a `.exe`,\n/// so we check the platform-appropriate extension.\npub(crate) fn has_package_manager(pm: crate::spacetime_config::PackageManager) -> bool {\n    let name = pm.to_string();\n    if cfg!(windows) {\n        // bun ships as bun.exe; npm, pnpm, yarn are .cmd shims\n        let ext = if name == \"bun\" { \"exe\" } else { \"cmd\" };\n        find_executable(format!(\"{name}.{ext}\")).is_some()","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/detect.rs#L33-L69","documentation":"has_wasm32_target (crates/cli/src/detect.rs:51) probes for the wasm32-unknown-unknown target by running `rustc --print target-libdir --target wasm32-unknown-unknown` and checking the printed path exists. Any failure in that probe (rustc not found on PATH, rustup shim errors, target not installed) is printed to stderr prefixed with this message and the function returns false - the error is swallowed, and callers then treat the wasm32 toolchain as absent (typically surfacing later as a 'target not installed' build hint).","triggerScenarios":"Running `spacetime build` (or anything that calls has_wasm32_target) when rustc is missing from PATH, when the active rustup toolchain lacks wasm32-unknown-unknown, or when the rustup proxy itself errors (broken installation, unmanaged toolchain override from rust-toolchain.toml).","commonSituations":"Fresh machines with rustup installed but targets missing; CI images where rustc is not on PATH for the shell invoking the CLI; project-level rust-toolchain.toml pinning a toolchain without the wasm target; broken rustup after a partial upgrade.","solutions":["Install the target into the active toolchain: `rustup target add wasm32-unknown-unknown`.","Verify the probe itself succeeds: `rustc --print target-libdir --target wasm32-unknown-unknown` must print an existing directory - if `rustc --version` fails, fix PATH or reinstall rustup first.","Check toolchain overrides (rust-toolchain.toml in the project or parents) resolve to a toolchain that has the target; add the target to that pinned toolchain.","Re-run `spacetime build` after fixing; the stderr warning should disappear."],"exampleFix":"# before\nspacetime build   # stderr: Error checking for wasm32 target: ... \n# after\nrustup target add wasm32-unknown-unknown\nspacetime build","handlingStrategy":"validation","validationCode":"// Preflight the toolchain before building modules.\nfn wasm_toolchain_ok() -> bool {\n    Command::new(\"rustc\").arg(\"--version\").output().map(|o| o.status.success()).unwrap_or(false)\n        && Command::new(\"rustc\")\n            .args([\"--print\", \"target-libdir\", \"--target\", \"wasm32-unknown-unknown\"])\n            .output()\n            .map(|o| o.status.success())\n            .unwrap_or(false)\n}\nassert!(wasm_toolchain_ok(), \"run: rustup target add wasm32-unknown-unknown\");","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Provision CI images with `rustup target add wasm32-unknown-unknown` baked in.","Check rust-toolchain.toml overrides also carry the wasm target for the pinned toolchain.","Treat the 'Error checking for wasm32 target' stderr line as a hard hint: fix rustc/PATH before investigating build failures downstream."],"tags":["spacetimedb","cli","rustup","wasm32","toolchain","build"],"backgroundTag":"wasm-target-not-installed","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}