{"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":"validation","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/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/tasks/cpp.rs#L42-L78","documentation":"`build_cpp`'s third PATH check looks for `emcmake` (`emcmake.bat` on Windows) — the CMake wrapper Emscripten ships that injects the emscripten toolchain file. Its absence while `cmake` was found typically means CMake came from the system but the emsdk environment is only partially active (or an emsdk version missing the wrapper).","triggerScenarios":"Emscripten activated in a different shell than the build; a manually-split emsdk installation where `emcc` is on PATH but `emcmake` is not; sourcing only part of the env; ancient emsdk versions without the wrapper script.","commonSituations":"Users adding `~/emsdk/upstream/emscripten` to PATH by hand instead of sourcing `emsdk_env.sh` (which also exposes the wrapper); mixed toolchains where system cmake is found first, masking an inactive emsdk; stale shells after moving the emsdk directory.","solutions":["Activate the full environment with `source ~/emsdk/emsdk_env.sh` rather than hand-adding to PATH","Check `which emcmake` resolves inside the emsdk tree, and that `emcc`/`emcmake` come from the same installation","Reinstall/activate the latest emsdk if the wrapper is genuinely missing","Reopen the terminal after activation so the updated PATH is in effect"],"exampleFix":"# before\nexport PATH=~/emsdk/upstream/emscripten:$PATH\nspacetime build .            # `emcmake` not found\n# after\nsource ~/emsdk/emsdk_env.sh\nspacetime build .","handlingStrategy":"validation","validationCode":"# Require the full emsdk env, not a hand-built PATH\ncommand -v emcmake >/dev/null && command -v emcc >/dev/null || { echo 'run: source emsdk_env.sh'; exit 2; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Activate emsdk with `emsdk_env.sh` instead of manually exporting partial paths","Check `which emcc emcmake` point into the same emsdk tree before building","Re-activate after moving or upgrading the emsdk directory"],"tags":["spacetimedb","cpp","emscripten","cmake","missing-toolchain"],"backgroundTag":"missing-build-tool","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}