clockworklabs/SpacetimeDB · error · anyhow::Error

`cmake` not found in PATH.

Error message

`cmake` not found in PATH.

What it means

After the `emcc` check, `build_cpp` likewise verifies that `cmake` (`cmake.exe` on Windows) is reachable on PATH, because the Emscripten project is configured and built through CMake. A missing system cmake aborts here, even when the Emscripten env itself is active.

Source

Thrown at crates/cli/src/tasks/cpp.rs:51

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?"));
    }

    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 = [

View on GitHub (pinned to 524b4487d9)

Solutions

  1. Install CMake (`apt install cmake`, `brew install cmake`, choco/winget on Windows, or via IDE/toolchain installer)
  2. Confirm `cmake --version` runs in the same shell used for `spacetime build`
  3. On CI, add cmake to the image or use an action that installs it
  4. If you installed cmake but still fail, reopen the terminal so PATH refreshes

Example fix

# before
spacetime build .            # `cmake` not found in PATH.
# after
sudo apt install cmake && spacetime build .
Defensive patterns

Strategy: validation

Validate before calling

command -v cmake >/dev/null || { echo 'cmake missing'; exit 2; }
spacetime build .

Prevention

When it happens

Trigger: Building a C/C++ module on a machine with emsdk activated but no system-wide CMake installed (or CMake not on PATH in the current shell).

Common situations: Minimal containers/CI images that skipped the cmake package; macOS/Linux without build-essential-style prereqs; PATH reordered so a broken cmake shim shadows the real one.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16). Data as JSON: /api/errors/f7700fa09f1a21f8. Report an issue: GitHub.