{"record":{"id":"c9ee2121eec6b359","repo":"clockworklabs/SpacetimeDB","slug":"emcc-not-found-in-path-activate-emscripten-ems","errorCode":null,"errorMessage":"`emcc` not found in PATH. Activate Emscripten (emsdk_env).","messagePattern":"`emcc` not found in PATH\\. Activate Emscripten \\(emsdk_env\\)\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/tasks/cpp.rs","lineNumber":42,"sourceCode":"    #[cfg(not(windows))]\n    {\n        duct::cmd(prog, args.iter().map(|s| s.as_ref()))\n            .dir(cwd)\n            .run()\n            .with_context(|| format!(\"failed running `{prog}`\"))?;\n    }\n    Ok(())\n}\n\npub(crate) fn build_cpp(project_path: &Path, build_debug: bool) -> anyhow::Result<PathBuf> {\n    // Verify required tools are in PATH\n    #[cfg(windows)]\n    let emcc_found = find_executable(\"emcc.bat\").is_some();\n    #[cfg(not(windows))]\n    let emcc_found = find_executable(\"emcc\").is_some();\n\n    if !emcc_found {\n        return Err(anyhow!(\"`emcc` not found in PATH. Activate Emscripten (emsdk_env).\"));\n    }\n\n    #[cfg(windows)]\n    let cmake_found = find_executable(\"cmake.exe\").is_some();\n    #[cfg(not(windows))]\n    let cmake_found = find_executable(\"cmake\").is_some();\n\n    if !cmake_found {\n        return Err(anyhow!(\"`cmake` not found in PATH.\"));\n    }\n\n    #[cfg(windows)]\n    let emcmake_found = find_executable(\"emcmake.bat\").is_some();\n    #[cfg(not(windows))]\n    let emcmake_found = find_executable(\"emcmake\").is_some();\n\n    if !emcmake_found {\n        return Err(anyhow!(\"`emcmake` not found in PATH. Is Emscripten env active?\"));","sourceCodeStart":24,"sourceCodeEnd":60,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/tasks/cpp.rs#L24-L60","documentation":"`build_cpp`, which compiles C/C++ modules to WebAssembly, first verifies toolchain availability by searching PATH for `emcc` (`emcc.bat` on Windows). Emscripten's compiler driver is mandatory for wasm output, so its absence aborts before any configure/build step with this message pointing at `emsdk_env`.","triggerScenarios":"Running `spacetime build` on a C/C++ module (detected via CMakeLists.txt) in a shell where the Emscripten SDK has not been activated — no `emcc` on PATH.","commonSituations":"New machine without emsdk installed; a new terminal where `emsdk_env.sh` was never sourced; CI images lacking Emscripten; IDE-launched terminals that don't inherit the shell profile where emsdk was activated.","solutions":["Install/activate Emscripten: `source ~/emsdk/emsdk_env.sh` (run `./emsdk install latest && ./emsdk activate latest` first if needed)","Verify with `emcc --version` in the exact shell you build from","Restart the terminal/IDE after activating so PATH propagates","On CI, add an emsdk setup step before `spacetime build`"],"exampleFix":"# before\nspacetime build .            # `emcc` not found in PATH\n# after\nsource ~/emsdk/emsdk_env.sh\nspacetime build .","handlingStrategy":"validation","validationCode":"# Fail fast if Emscripten isn't active\ncommand -v emcc >/dev/null || { echo 'emsdk not active'; exit 2; }\nspacetime build .","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Source `emsdk_env.sh` in shell profiles or build scripts that invoke `spacetime build` for C/C++","Add an `emcc --version` preflight step in CI before building modules","Install emsdk once per machine/CI image and activate it in every relevant shell"],"tags":["spacetimedb","cpp","emscripten","missing-toolchain","environment"],"backgroundTag":"missing-build-tool","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}