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
`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).
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 524b4487d9)
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
Example fix
# before export PATH=~/emsdk/upstream/emscripten:$PATH spacetime build . # `emcmake` not found # after source ~/emsdk/emsdk_env.sh spacetime build .
Defensive patterns
Strategy: validation
Validate before calling
# Require the full emsdk env, not a hand-built PATH
command -v emcmake >/dev/null && command -v emcc >/dev/null || { echo 'run: source emsdk_env.sh'; exit 2; } Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- `emcc` not found in PATH. Activate Emscripten (emsdk_env).
- `cmake` not found in PATH.
- Built successfully but couldn't find a .wasm under {}
- ERROR: Skipping multi-column index registration '%s.%s' beca
- ERROR: Skipping default-value registration '%s.%s' because c
AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16).
Data as JSON: /api/errors/3cb69972fb8a8335.
Report an issue: GitHub.