{"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/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/util.rs#L266-L302","documentation":"Thrown by detect_module_language when the module directory exists but contains none of the markers the CLI recognizes: Cargo.toml (Rust), any *.csproj (C#), package.json (JavaScript/TypeScript), or CMakeLists.txt (C++). Without a marker the CLI cannot decide which toolchain to use to build the module.","triggerScenarios":"Running spacetime build/publish inside a plain directory or fresh git repo that has no module scaffold; pointing --module-path at the repo root when the module is nested deeper; a module written in a language SpacetimeDB does not support; an empty directory after a partial clone or missing git submodules.","commonSituations":"Forgot to run `spacetime init`; cloned a project without initializing submodules; renamed or moved the module crate so its manifest file is no longer in the expected directory.","solutions":["Point the CLI at the directory that actually contains Cargo.toml, package.json, or a .csproj: `spacetime build --module-path ./module-crate`.","Scaffold a new module: `spacetime init --lang <rust|csharp|typescript|cpp> <path>`.","If submodules are missing: `git submodule update --init --recursive`.","If the module is in an unsupported language, rewrite it in a supported one."],"exampleFix":"# before — run from repo root, no manifest visible\nspacetime build\n# after — point at the crate that contains Cargo.toml\nspacetime build --module-path ./module-server","handlingStrategy":"validation","validationCode":"fn is_supported_module(dir: &std::path::Path) -> bool {\n    if dir.join(\"Cargo.toml\").exists() || dir.join(\"package.json\").exists() || dir.join(\"CMakeLists.txt\").exists() {\n        return true;\n    }\n    std::fs::read_dir(dir).map(|rd| rd.flatten().any(|e| e.path().extension().is_some_and(|x| x == \"csproj\"))).unwrap_or(false)\n}\n// call before invoking the CLI\nassert!(is_supported_module(path.as_ref()), \"no Rust/C#/JS/C++ manifest in {}\", path.display());","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Run `spacetime init` to scaffold before building.","Keep the module manifest at the root of the module-path directory.","Initialize git submodules after cloning."],"tags":["spacetimedb","cli","language-detection","build","project-structure"],"backgroundTag":"project-language-detection-failed","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}