{"record":{"id":"fb412958701d0c3e","repo":"clockworklabs/SpacetimeDB","slug":"wasm32-unknown-unknown-target-is-not-installed-pl","errorCode":null,"errorMessage":"wasm32-unknown-unknown target is not installed. Please install it.","messagePattern":"wasm32-unknown-unknown target is not installed\\. Please install it\\.","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/tasks/rust.rs","lineNumber":39,"sourceCode":"        .chain((!build_debug).then_some(\"--release\"))\n        .chain(args.iter().copied()),\n    )\n}\n\npub(crate) fn build_rust(\n    project_path: &Path,\n    features: Option<&std::ffi::OsString>,\n    lint_dir: Option<&Path>,\n    build_debug: bool,\n) -> anyhow::Result<PathBuf> {\n    // Make sure that we have the wasm target installed\n    if !has_wasm32_target() {\n        if has_rust_up() {\n            cmd!(\"rustup\", \"target\", \"add\", \"wasm32-unknown-unknown\")\n                .run()\n                .context(\"Failed to install wasm32-unknown-unknown target with rustup\")?;\n        } else {\n            anyhow::bail!(\"wasm32-unknown-unknown target is not installed. Please install it.\");\n        }\n    }\n\n    if let Some(lint_dir) = lint_dir {\n        let mut err_count: u32 = 0;\n        let lint_dir = project_path.join(lint_dir);\n        for file in walkdir::WalkDir::new(lint_dir).into_iter() {\n            let file = file?;\n            let printable_path = file.path().to_str().ok_or(anyhow::anyhow!(\"path not utf-8\"))?;\n            if file.file_type().is_file() && file.path().extension().is_some_and(|ext| ext == \"rs\") {\n                let file = fs::File::open(file.path())?;\n                for (idx, line) in io::BufReader::new(file).lines().enumerate() {\n                    let line = line?;\n                    let line_number = idx + 1;\n                    for disallowed in &[\"println!\", \"print!\", \"eprintln!\", \"eprint!\", \"dbg!\"] {\n                        if line.contains(disallowed) {\n                            if err_count == 0 {\n                                eprintln!(\"\\nDetected nonfunctional print statements:\\n\");","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/tasks/rust.rs#L21-L57","documentation":"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.","triggerScenarios":"`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.","commonSituations":"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.","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."],"exampleFix":"# before: Dockerfile with system rustc only\nRUN apt-get install -y rustc cargo\n# after\nRUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y\nRUN $HOME/.cargo/bin/rustup target add wasm32-unknown-unknown","handlingStrategy":"validation","validationCode":"# Fail fast before building if the wasm target is missing and rustup is absent\ncommand -v rustup >/dev/null 2>&1 || \\\n  rustc --print target-libdir --target wasm32-unknown-unknown >/dev/null 2>&1 || \\\n  { echo 'install wasm32-unknown-unknown (no rustup to auto-install it)' >&2; exit 1; }\nspacetime build","typeGuard":null,"tryCatchPattern":null,"preventionTips":["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`."],"tags":["rust","wasm","compile-target","toolchain","rustup"],"backgroundTag":"missing-compile-target","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}