{"record":{"id":"3cb69972fb8a8335","repo":"clockworklabs/SpacetimeDB","slug":"emcmake-not-found-in-path-is-emscripten-env-act","errorCode":null,"errorMessage":"`emcmake` not found in PATH. Is Emscripten env active?","messagePattern":"`emcmake` not found in PATH\\. Is Emscripten env active\\?","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/tasks/cpp.rs","lineNumber":60,"sourceCode":"        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?\"));\n    }\n\n    let build_type = if build_debug { \"Debug\" } else { \"Release\" };\n    let build_dir = project_path.join(\"build\");\n\n    // === Configure (no generator flags; let emcmake/cmake decide or reuse existing) ===\n    // This matches: emcmake cmake -B build .\n    // We keep -S/-B so `project_path` can be anywhere, and pass CMAKE_BUILD_TYPE (ignored by multi-config).\n    let cfg_args = [\n        \"cmake\",\n        \"-S\",\n        \".\",\n        \"-B\",\n        \"build\",\n        &format!(\"-DCMAKE_BUILD_TYPE={}\", build_type),\n    ];\n    run_command(\"emcmake\", &cfg_args, project_path).context(\"Failed to configure C++ project with emcmake/cmake\")?;\n","sourceCodeStart":42,"sourceCodeEnd":78,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/tasks/cpp.rs#L42-L78","documentation":"Third preflight in build_cpp: emcmake (Emscripten's CMake wrapper, emcmake / emcmake.bat) is not on PATH. emcmake ships with the emsdk toolchain and configures CMake with the Emscripten compilers; its absence means the Emscripten environment is only partially active.","triggerScenarios":"`spacetime build` on a C/C++ module where emcc/cmake resolve but emcmake does not — typically a hand-crafted PATH that added emsdk's emscripten folder incompletely, or an emsdk activation that was only partially sourced.","commonSituations":"Manually exporting only some emsdk paths; mixing a system cmake with a partial Emscripten install; stale shells from before an emsdk upgrade.","solutions":["Activate the full environment with `source <emsdk-path>/emsdk_env.sh` rather than hand-picking binaries","Verify `which emcmake` (it lives under emsdk/upstream/emscripten/) and that emcc sits beside it","If emsdk is broken, re-run `./emsdk install latest && ./emsdk activate latest`"],"exampleFix":"# before\nexport PATH=~/emsdk/upstream/emscripten:$PATH   # emcc works, emcmake missing\n\n# after\nsource ~/emsdk/emsdk_env.sh                      # activates the full toolchain","handlingStrategy":"validation","validationCode":"# bash: verify the Emscripten CMake wrapper exists\ncommand -v emcmake >/dev/null || { echo \"run: source <emsdk>/emsdk_env.sh\" >&2; exit 1; }\nspacetime build","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Activate emsdk with its env script rather than hand-exporting individual tool paths","After emsdk upgrades, refresh open shells so emcmake and emcc come from the same toolchain"],"tags":["build","cpp","emscripten","cmake","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"}