{"record":{"id":"0a40187f97442442","repo":"clockworklabs/SpacetimeDB","slug":"could-not-find-module-source-at-if-this-is-n","errorCode":null,"errorMessage":"Could not find module source at '{}'. If this is not correct, pass --module-path or add module-path in spacetime.json. You can also pass --bin-path/--js-path to generate without building from source,","messagePattern":"Could not find module source at '(.+?)'\\. If this is not correct, pass --module-path or add module-path in spacetime\\.json\\. You can also pass --bin-path/--js-path to generate without building from source,","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/generate.rs","lineNumber":354,"sourceCode":"            command_config.get_one::<u8>(\"dotnet_version\")?\n        } else {\n            let dotnet_version = command_config.get_one::<String>(\"dotnet_version\")?;\n            parse_optional_dotnet_version(dotnet_version.as_deref())?\n        };\n\n        // Validate Unreal-specific args first to preserve focused errors for this mode.\n        if requested_lang == Some(Language::UnrealCpp) {\n            if command_config.get_one::<PathBuf>(\"uproject_dir\")?.is_none() {\n                return Err(anyhow::anyhow!(\"--uproject-dir is required for --lang unrealcpp\"));\n            }\n            if module_name.is_none() {\n                return Err(anyhow::anyhow!(\"--unreal-module-name is required for --lang unrealcpp\"));\n            }\n        }\n\n        // Validate module source path for source-based generation.\n        if wasm_file.is_none() && js_file.is_none() && !project_path.is_dir() {\n            anyhow::bail!(\n                \"Could not find module source at '{}'. \\\n                 If this is not correct, pass --module-path or add module-path in spacetime.json. \\\n                 You can also pass --bin-path/--js-path to generate without building from source.\",\n                project_path.display()\n            );\n        }\n\n        let lang = match requested_lang {\n            Some(lang) => lang,\n            None => {\n                let client_project_dir = config_dir.unwrap_or_else(|| Path::new(\".\"));\n                let detected = detect_default_language(client_project_dir)?;\n                println!(\n                    \"Detected client language '{}' from '{}'. If this is not correct, pass --lang or add a generate target in spacetime.json.\",\n                    language_cli_name(detected),\n                    client_project_dir.display()\n                );\n                detected","sourceCodeStart":336,"sourceCodeEnd":372,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/generate.rs#L336-L372","documentation":"When neither `--bin-path` nor `--js-path` is supplied, `spacetime generate` builds your module from source, so the module directory (resolved from `--module-path`, the spacetime.json `module-path` field, or a default location) must exist and be a directory. If it doesn't, generate aborts before invoking any build toolchain. Passing a prebuilt artifact path skips this check entirely.","triggerScenarios":"`spacetime generate` in a repo where the module source directory doesn't exist at the resolved path; a typo'd `--module-path`; having only a prebuilt module.wasm/module.js but not passing `--bin-path`/`--js-path`.","commonSituations":"Running generate at repo root while the module lives under `crates/module` or similar; renamed module folder; CI checkouts that skip the module directory; attempting offline generation without a toolchain but forgetting the prebuilt flags.","solutions":["Run from the project root that contains the module directory, or pass `--module-path path/to/module`","Set `\"module-path\"` on the target in spacetime.json","Skip the build with `--bin-path target/wasm32-unknown-unknown/release/module.wasm` (or `--js-path` for TypeScript modules)","Check the path for typos and case sensitivity"],"exampleFix":"# before — fails: ./module does not exist\nspacetime generate\n\n# after — build from source elsewhere\nspacetime generate --module-path crates/server-module\n\n# after — no build, use prebuilt wasm\nspacetime generate --bin-path target/wasm32-unknown-unknown/release/module.wasm","handlingStrategy":"validation","validationCode":"# Before generate-from-source, verify the module dir:\nMODULE_DIR=\"${MODULE_PATH:-module}\"\nif [[ -z \"$BIN_PATH\" && -z \"$JS_PATH\" && ! -d \"$MODULE_DIR\" ]]; then\n  echo \"module source '$MODULE_DIR' missing — pass --module-path or --bin-path\" >&2\n  exit 2\nfi\nspacetime generate","typeGuard":null,"tryCatchPattern":"#!/usr/bin/env bash\nif ! spacetime generate 2>err.log; then\n  if grep -q \"Could not find module source\" err.log; then\n    # fall back to the last known-good prebuilt wasm instead of failing the pipeline\n    spacetime generate --bin-path \"$PREBUILT_WASM\" || exit 1\n  else\n    cat err.log >&2; exit 1\n  fi\nfi","preventionTips":["Pin `module-path` in spacetime.json so generate works from any working directory","In CI, either check out the module source or pass an artifact via --bin-path/--js-path","Verify the module directory exists in a preflight step of build scripts"],"tags":["generate","module-path","filesystem","build"],"backgroundTag":"module-source-path-missing","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}