clockworklabs/SpacetimeDB · error · anyhow::Error
Built successfully but couldn't find a .wasm under {}
Error message
Built successfully but couldn't find a .wasm under {} What it means
After the CMake build reports success, `build_cpp` walks the `build/` directory looking for any `*.wasm`, keeping the most recently modified match. If the recursive scan finds none, it returns this error with the build dir path: the toolchain ran, but produced no WebAssembly artifact where the CLI expects it.
Source
Thrown at crates/cli/src/tasks/cpp.rs:104
// picking up an older cached wasm file from a previous build
let wasm = WalkDir::new(&build_dir)
.into_iter()
.filter_map(Result::ok)
.filter_map(|e| {
let p = e.path();
if p.extension().and_then(|s| s.to_str()) == Some("wasm") {
e.metadata()
.ok()
.and_then(|m| m.modified().ok())
.map(|mtime| (p.to_path_buf(), mtime))
} else {
None
}
})
.max_by_key(|(_, mtime)| *mtime)
.map(|(path, _)| path)
.ok_or_else(|| {
anyhow!(
"Built successfully but couldn't find a .wasm under {}",
build_dir.display()
)
})?;
Ok(wasm)
}
View on GitHub (pinned to 524b4487d9)
Solutions
- Delete the `build/` directory and rebuild with the emsdk env fully active, forcing reconfiguration with the Emscripten toolchain
- Inspect the project's CMakeLists for custom output directories and either point the build at `build/` or adjust expectations
- Verify the build actually targets wasm: look for `.wasm`-producing targets and check CMake cache toolchain settings in `build/CMakeCache.txt`
- Run `find <project>/build -name '*.wasm'` manually to see whether an artifact lands elsewhere
Example fix
# before spacetime build . # built, but no .wasm under build/ # after rm -rf build && source ~/emsdk/emsdk_env.sh && spacetime build .
Defensive patterns
Strategy: validation
Validate before calling
# After a clean build, assert the artifact exists where the CLI expects it find build -name '*.wasm' | grep -q . || echo 'no wasm produced — check toolchain config'
Prevention
- Delete `build/` before building whenever the emsdk activation state changed, so CMake can't reuse a native-toolchain cache
- Confirm CMakeLists emits its wasm target into the build directory (default CMAKE output paths)
- Verify `CMAKE_C_COMPILER` in build/CMakeCache.txt points at emcc after configuring
When it happens
Trigger: emcmake/cmake falling back to the host toolchain (producing native ELF/DLL objects instead of wasm because the Emscripten toolchain file wasn't applied to a stale or pre-existing CMake cache); a CMakeLists whose wasm-producing target writes outside `build/`; build artifacts cleaned by an external step between build and scan.
Common situations: A `build/` directory configured before emsdk activation, so CMake reuses a native generator cache; projects that copy/post-process outputs to `dist/`; custom output paths via `set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ...)` pointing elsewhere.
Related errors
- `cmake` not found in PATH.
- `emcmake` not found in PATH. Is Emscripten env active?
- `emcc` not found in PATH. Activate Emscripten (emsdk_env).
- should have a pending mutable anon tx as `procedure_start_mu
- ERROR: Skipping multi-column index registration '%s.%s' beca
AI-assisted analysis of clockworklabs/SpacetimeDB@524b4487d9 (2026-08-16).
Data as JSON: /api/errors/43becfc94de78b91.
Report an issue: GitHub.