{"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":"exception","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/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/tasks/cpp.rs#L24-L60","documentation":"build_cpp, which compiles C/C++ modules to WebAssembly, preflights PATH for the Emscripten compiler driver (emcc / emcc.bat on Windows) and bails before configuring anything. Without emcc no WASM module can be produced, so the build stops immediately with a pointer to emsdk_env.","triggerScenarios":"`spacetime build` (or publish) on a module whose directory contains CMakeLists.txt, in a shell where Emscripten's environment has not been activated or was never installed.","commonSituations":"Fresh machines; opening a new terminal after installing emsdk (activation is per-shell); CI images without emsdk; Windows sessions where emsdk_env.bat was not run.","solutions":["Activate Emscripten in this shell: `source <emsdk-path>/emsdk_env.sh` (Windows: `emsdk_env.bat`)","If not installed: `git clone https://github.com/emscripten-core/emsdk && cd emsdk && ./emsdk install latest && ./emsdk activate latest`","Verify with `emcc --version`, then re-run `spacetime build`"],"exampleFix":"# before\nspacetime build            # emcc not found in PATH\n\n# after\nsource ~/emsdk/emsdk_env.sh\nspacetime build","handlingStrategy":"validation","validationCode":"# bash: preflight the C/C++ toolchain before building\nfor t in emcc cmake emcmake; do command -v \"$t\" >/dev/null || { echo \"missing $t — source emsdk_env.sh\" >&2; exit 1; }; done\nspacetime build","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Source emsdk_env.sh in every shell/script that builds C/C++ modules (activation is per-shell)","Bake emsdk activation into dev containers so PATH is always correct"],"tags":["build","cpp","wasm","emscripten","environment"],"backgroundTag":"missing-build-tool","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"}