zeroclaw-labs/zeroclaw · error · anyhow::Error

WASM module not found: {} (looked in {})

Error message

WASM module not found: {} (looked in {})

What it means

WasmPlatform::execute_module resolves the module as {tools_dir}/{module_name}.wasm (tools_dir being workspace-relative per error 871/872 rules) and bails when that file does not exist, including both the requested module name and the directory it searched. Everything after this (size check, compilation, execution) only runs once the file is present.

Source

Thrown at crates/zeroclaw-runtime/src/platform/wasm.rs:135

        };
        mb.saturating_mul(1024 * 1024)
    }

    #[cfg(feature = "runtime-wasm")]
    pub fn execute_module(
        &self,
        module_name: &str,
        workspace_dir: &Path,
        caps: &WasmCapabilities,
    ) -> Result<WasmExecutionResult> {
        use wasmi::{Engine, Linker, Module, Store};

        // Resolve module path
        let tools_path = self.tools_dir(workspace_dir);
        let module_path = tools_path.join(format!("{module_name}.wasm"));

        if !module_path.exists() {
            bail!(
                "WASM module not found: {} (looked in {})",
                module_name,
                tools_path.display()
            );
        }

        // Read module bytes
        let wasm_bytes = std::fs::read(&module_path)
            .with_context(|| format!("Failed to read WASM module: {}", module_path.display().to_string()))?;

        // Validate module size (sanity check)
        if wasm_bytes.len() > 50 * 1024 * 1024 {
            bail!(
                "WASM module {} is {} MB — exceeds 50 MB safety limit",
                module_name,
                wasm_bytes.len() / (1024 * 1024)
            );
        }

View on GitHub (pinned to 88bb9c8533)

Solutions

  1. Compare the module name with the actual filename in the searched directory printed in the error; fix typos/case
  2. Ensure the file exists at <workspace>/<tools_dir>/<module_name>.wasm — build or copy it there
  3. Fix runtime.wasm.tools_dir if it points at the wrong location
  4. Pass the bare module name without the .wasm extension

Example fix

# before: file is tools/wasm/toolsy.wasm, or missing
platform.execute_module("tool", ...)

# after: ls tools/wasm shows tool.wasm
platform.execute_module("tool", ...)
Defensive patterns

Strategy: validation

Validate before calling

let module_path = workspace_dir
    .join(&cfg.tools_dir)
    .join(format!("{module_name}.wasm"));
if !module_path.is_file() {
    // surface 'missing module <name> in <dir>' before calling execute_module
}

Try / catch

match platform.execute_module(name, &ws, &caps) {
    Err(e) if e.to_string().contains("WASM module not found") => {
        // deployment gap: build/copy the module into the searched dir; not a runtime bug
    }
    other => other?,
}

Prevention

When it happens

Trigger: Requesting a module that was never built/downloaded into the tools directory; module name typos or wrong case (the lookup is a plain filesystem join, case-sensitive on Linux); tools_dir misconfigured so the search happens in the wrong directory; appending '.wasm' yourself so it looks for module.wasm.wasm.

Common situations: Fresh clones missing compiled artifacts because tools are build outputs; CI running before a wasm build step; module renamed in the repo but callers still use the old name; macOS dev (case-insensitive FS) deploying to Linux (case-sensitive) and hitting case mismatches.

Related errors


AI-assisted analysis of zeroclaw-labs/zeroclaw@88bb9c8533 (2026-08-23). Data as JSON: /api/errors/5d1506e5b0fa49af. Report an issue: GitHub.