{"record":{"id":"89754e51948b4e69","repo":"clockworklabs/SpacetimeDB","slug":"module-directory-does-not-exist-check-your","errorCode":null,"errorMessage":"Module directory does not exist: '{}'. Check your --module-path flag or the module-path setting in spacetime.json.","messagePattern":"Module directory does not exist: '(.+?)'\\. Check your --module-path flag or the module-path setting in spacetime\\.json\\.","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/util.rs","lineNumber":262,"sourceCode":"/// 1. `{project_dir}/spacetimedb/` subdirectory\n/// 2. `{project_dir}` itself\n///\n/// Returns the first path that contains a recognizable SpacetimeDB module, or `None`.\npub fn find_module_path(project_dir: &Path) -> Option<PathBuf> {\n    let spacetimedb_subdir = project_dir.join(\"spacetimedb\");\n    if spacetimedb_subdir.is_dir() && detect_module_language(&spacetimedb_subdir).is_ok() {\n        return Some(spacetimedb_subdir);\n    }\n    if project_dir.is_dir() && detect_module_language(project_dir).is_ok() {\n        return Some(project_dir.to_path_buf());\n    }\n    None\n}\n\npub fn detect_module_language(path_to_module: &Path) -> anyhow::Result<ModuleLanguage> {\n    // TODO: Possible add a config file durlng spacetime init with the language\n    if !path_to_module.exists() {\n        anyhow::bail!(\n            \"Module directory does not exist: '{}'. \\\n             Check your --module-path flag or the module-path setting in spacetime.json.\",\n            path_to_module.display()\n        );\n    }\n    // check for Cargo.toml\n    if path_to_module.join(\"Cargo.toml\").exists() {\n        Ok(ModuleLanguage::Rust)\n    } else if path_to_module.is_dir()\n        && path_to_module\n            .read_dir()\n            .map_err(|e| anyhow::anyhow!(\"Failed to read directory {}: {}\", path_to_module.display(), e))?\n            .flatten()\n            .any(|entry| entry.path().extension() == Some(\"csproj\".as_ref()))\n    {\n        Ok(ModuleLanguage::Csharp)\n    } else if path_to_module.join(\"package.json\").exists() {\n        Ok(ModuleLanguage::Javascript)","sourceCodeStart":244,"sourceCodeEnd":280,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/util.rs#L244-L280","documentation":"Before probing a module's language, detect_module_language verifies that the module path exists at all. The path comes from the --module-path flag or the module-path setting in spacetime.json. A nonexistent path fails fast with this message instead of producing a confusing language-detection error later.","triggerScenarios":"spacetime build/publish with --module-path pointing at a missing, renamed, or mistyped directory; running the CLI from a different working directory so a relative path no longer resolves; spacetime.json's module-path holding a stale location from another machine.","commonSituations":"Project folder moved or renamed after spacetime.json was written; a cloned repo carrying an absolute module-path; CI checkout layout differing from local; simple typo in the flag.","solutions":["Verify the path exists: `ls` the directory you passed","Run the CLI from the project root, or pass an absolute --module-path","Fix the module-path value in spacetime.json","If the module was deleted or never created, scaffold it with `spacetime init`"],"exampleFix":"# before\n$ spacetime build --module-path ./src\nerror: Module directory does not exist: './src'\n\n# after: point at the actual module directory\n$ spacetime build --module-path ./crates/module","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n[ -d \"$MODULE_PATH\" ] || { echo \"module dir missing: $MODULE_PATH\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use absolute module paths in CI and scripts","Validate spacetime.json's module-path before invoking the CLI","Run the CLI from the project root by convention","Fail fast in deploy scripts with a friendly message instead of letting the CLI error"],"tags":["cli","filesystem","configuration","module-path"],"backgroundTag":"file-not-found","analyzedSha":"6dee26c6efc2856793e12b148a59742964f5d783","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}