clockworklabs/SpacetimeDB · error · anyhow::Error
`emcmake` not found in PATH. Is Emscripten env active?
Error message
`emcmake` not found in PATH. Is Emscripten env active?
What it means
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.
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`
Example fix
# before export PATH=~/emsdk/upstream/emscripten:$PATH # emcc works, emcmake missing # after source ~/emsdk/emsdk_env.sh # activates the full toolchain
Defensive patterns
Strategy: validation
Validate before calling
# bash: verify the Emscripten CMake wrapper exists
command -v emcmake >/dev/null || { echo "run: source <emsdk>/emsdk_env.sh" >&2; exit 1; }
spacetime build Prevention
- 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
When it happens
Trigger: `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.
Common situations: Manually exporting only some emsdk paths; mixing a system cmake with a partial Emscripten install; stale shells from before an emsdk upgrade.
Related errors
- `cmake` not found in PATH.
- `emcc` not found in PATH. Activate Emscripten (emsdk_env).
- Cannot extract accessor name from query
- Cannot read environment schema: HTTP
- [CIRCULAR REFERENCE ERROR] Module cleared and replaced with…
AI-assisted analysis of clockworklabs/SpacetimeDB@6dee26c6ef (2026-08-20).
Data as JSON: /api/errors/3cb69972fb8a8335.
Report an issue: GitHub.
Appendix: source
Thrown at crates/cli/src/tasks/cpp.rs:60
return Err(anyhow!("`emcc` not found in PATH. Activate Emscripten (emsdk_env)."));
}
#[cfg(windows)]
let cmake_found = find_executable("cmake.exe").is_some();
#[cfg(not(windows))]
let cmake_found = find_executable("cmake").is_some();
if !cmake_found {
return Err(anyhow!("`cmake` not found in PATH."));
}
#[cfg(windows)]
let emcmake_found = find_executable("emcmake.bat").is_some();
#[cfg(not(windows))]
let emcmake_found = find_executable("emcmake").is_some();
if !emcmake_found {
return Err(anyhow!("`emcmake` not found in PATH. Is Emscripten env active?"));
}
let build_type = if build_debug { "Debug" } else { "Release" };
let build_dir = project_path.join("build");
// === Configure (no generator flags; let emcmake/cmake decide or reuse existing) ===
// This matches: emcmake cmake -B build .
// We keep -S/-B so `project_path` can be anywhere, and pass CMAKE_BUILD_TYPE (ignored by multi-config).
let cfg_args = [
"cmake",
"-S",
".",
"-B",
"build",
&format!("-DCMAKE_BUILD_TYPE={}", build_type),
];
run_command("emcmake", &cfg_args, project_path).context("Failed to configure C++ project with emcmake/cmake")?;
View on GitHub (pinned to 6dee26c6ef)