{"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/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/util.rs#L244-L280","documentation":"Thrown by detect_module_language in the SpacetimeDB CLI when the module path resolved from --module-path, the module-path setting in spacetime.json, or the auto-detected project directory does not exist on disk. The CLI refuses to build or publish because it cannot inspect the directory to determine the module language (Rust, C#, JavaScript/TypeScript, or C++). It always indicates a wrong or stale path, not a broken project.","triggerScenarios":"Running `spacetime build` or `spacetime publish` with --module-path pointing to a nonexistent directory; a spacetime.json whose module-path value is stale or machine-specific; running the CLI from a working directory where find_module_dir can find neither a valid ./spacetime submodule dir nor a valid project dir.","commonSituations":"Typos or wrong case in --module-path; running commands from the repo root instead of the module crate directory; spacetime.json committed with an absolute path from another machine; moving or renaming the project folder after `spacetime init`.","solutions":["Verify the directory exists (`ls <module-path>`) and fix typos or case sensitivity.","Pass an explicit absolute path: `spacetime build --module-path /abs/path/to/module`.","Check the module-path field in spacetime.json and make it relative to the config file or correct for the current layout.","Run the command from inside the SpacetimeDB project directory (the one containing Cargo.toml, package.json, or a .csproj).","If the module was never created, scaffold it first with `spacetime init`."],"exampleFix":"// spacetime.json (before) — machine-specific absolute path\n{ \"module-path\": \"/home/me/old-path/module\" }\n// after — portable relative path\n{ \"module-path\": \"./module\" }","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\nMODULE_PATH=\"${1:-.}\"\nif [ ! -d \"$MODULE_PATH\" ]; then\n  echo \"module path '$MODULE_PATH' does not exist — fix --module-path / spacetime.json\" >&2\n  exit 1\nfi\nspacetime build --module-path \"$(cd \"$MODULE_PATH\" && pwd)\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always pass an absolute --module-path in CI scripts.","Keep module-path in spacetime.json relative to the config file, never absolute.","Run `spacetime init` before build in freshly cloned repositories."],"tags":["spacetimedb","cli","module-path","filesystem","build"],"backgroundTag":"module-path-not-found","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}