clockworklabs/SpacetimeDB · error · anyhow::Error
`emcc` not found in PATH. Activate Emscripten (emsdk_env).
Error message
`emcc` not found in PATH. Activate Emscripten (emsdk_env).
What it means
`build_cpp`, which compiles C/C++ modules to WebAssembly, first verifies toolchain availability by searching PATH for `emcc` (`emcc.bat` on Windows). Emscripten's compiler driver is mandatory for wasm output, so its absence aborts before any configure/build step with this message pointing at `emsdk_env`.
Source
Thrown at crates/cli/src/tasks/cpp.rs:42
#[cfg(not(windows))]
{
duct::cmd(prog, args.iter().map(|s| s.as_ref()))
.dir(cwd)
.run()
.with_context(|| format!("failed running `{prog}`"))?;
}
Ok(())
}
pub(crate) fn build_cpp(project_path: &Path, build_debug: bool) -> anyhow::Result<PathBuf> {
// Verify required tools are in PATH
#[cfg(windows)]
let emcc_found = find_executable("emcc.bat").is_some();
#[cfg(not(windows))]
let emcc_found = find_executable("emcc").is_some();
if !emcc_found {
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?"));View on GitHub (pinned to 524b4487d9)
Solutions
- Install/activate Emscripten: `source ~/emsdk/emsdk_env.sh` (run `./emsdk install latest && ./emsdk activate latest` first if needed)
- Verify with `emcc --version` in the exact shell you build from
- Restart the terminal/IDE after activating so PATH propagates
- On CI, add an emsdk setup step before `spacetime build`
Example fix
# before spacetime build . # `emcc` not found in PATH # after source ~/emsdk/emsdk_env.sh spacetime build .
Defensive patterns
Strategy: validation
Validate before calling
# Fail fast if Emscripten isn't active
command -v emcc >/dev/null || { echo 'emsdk not active'; exit 2; }
spacetime build . Prevention
- Source `emsdk_env.sh` in shell profiles or build scripts that invoke `spacetime build` for C/C++
- Add an `emcc --version` preflight step in CI before building modules
- Install emsdk once per machine/CI image and activate it in every relevant shell
When it happens
Trigger: Running `spacetime build` on a C/C++ module (detected via CMakeLists.txt) in a shell where the Emscripten SDK has not been activated — no `emcc` on PATH.
Common situations: New machine without emsdk installed; a new terminal where `emsdk_env.sh` was never sourced; CI images lacking Emscripten; IDE-launched terminals that don't inherit the shell profile where emsdk was activated.
Related errors
- `cmake` not found in PATH.
- `emcmake` not found in PATH. Is Emscripten env active?
- 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/c9ee2121eec6b359.
Report an issue: GitHub.