{"record":{"id":"22cf0e49ffa26f26","repo":"clockworklabs/SpacetimeDB","slug":"could-not-detect-the-language-of-the-module-are-y","errorCode":null,"errorMessage":"Could not detect the language of the module. Are you in a SpacetimeDB project directory?","messagePattern":"Could not detect the language of the module\\. Are you in a SpacetimeDB project directory\\?","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/util.rs","lineNumber":284,"sourceCode":"        );\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)\n    } else if path_to_module.join(\"CMakeLists.txt\").exists() {\n        Ok(ModuleLanguage::Cpp)\n    } else {\n        anyhow::bail!(\"Could not detect the language of the module. Are you in a SpacetimeDB project directory?\")\n    }\n}\n\npub fn url_to_host_and_protocol(url: &str) -> anyhow::Result<(&str, &str)> {\n    if contains_protocol(url) {\n        let protocol = url.split(\"://\").next().unwrap();\n        let host = url.split(\"://\").last().unwrap();\n\n        if !VALID_PROTOCOLS.contains(&protocol) {\n            Err(anyhow::anyhow!(\"Invalid protocol: {protocol}\"))\n        } else {\n            Ok((host, protocol))\n        }\n    } else {\n        Err(anyhow::anyhow!(\"Invalid url: {url}\"))\n    }\n}\n","sourceCodeStart":266,"sourceCodeEnd":302,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/6dee26c6efc2856793e12b148a59742964f5d783/crates/cli/src/util.rs#L266-L302","documentation":"Module language detection is marker-file based: Cargo.toml means Rust, any *.csproj directly inside the directory means C#, package.json means JavaScript, CMakeLists.txt means C++. When the directory exists but contains none of these markers, the CLI cannot decide how to build the module and bails with this message.","triggerScenarios":"Running spacetime build/publish in an empty or unrelated directory; a module dir whose marker file is missing (Cargo.toml deleted, .csproj only in a subfolder, package.json not at the module root); pointing --module-path at the repo root instead of the module crate.","commonSituations":"Wrong cwd when invoking the CLI; freshly created directory never initialized; nested monorepo layout where the marker file sits one level deeper than the path given.","solutions":["cd into the actual module directory or pass --module-path to it","Create/restore the marker file: `cargo init` for Rust, restore the .csproj, package.json, or CMakeLists.txt","If no project exists yet, scaffold one with `spacetime init`","For C#, ensure the .csproj is directly inside the module dir, not in a child folder"],"exampleFix":"# before: cwd contains no marker file\n$ spacetime build\nerror: Could not detect the language of the module.\n\n# after: build from the directory containing Cargo.toml\n$ cd module && spacetime build","handlingStrategy":"validation","validationCode":"#!/usr/bin/env bash\n[ -f Cargo.toml ] || [ -f package.json ] || [ -f CMakeLists.txt ] || compgen -G '*.csproj' >/dev/null \\\n  || { echo 'not a SpacetimeDB module dir (no marker file)' >&2; exit 1; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Always invoke the CLI from the module root or pass --module-path explicitly","Keep the marker file (Cargo.toml/package.json/.csproj/CMakeLists.txt) at the module dir top level","Scaffold new modules with spacetime init so the layout is correct from the start","In monorepos, script a mapping from project name to module dir"],"tags":["cli","project-detection","module","configuration"],"backgroundTag":"project-type-detection-failed","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"}