{"record":{"id":"5f5880ad2967f15a","repo":"clockworklabs/SpacetimeDB","slug":"uproject-dir-is-required-for-lang-unrealcpp","errorCode":null,"errorMessage":"--uproject-dir is required for --lang unrealcpp","messagePattern":"--uproject-dir is required for --lang unrealcpp","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/generate.rs","lineNumber":345,"sourceCode":"        let namespace = command_config\n            .get_one::<String>(\"namespace\")?\n            .unwrap_or_else(|| \"SpacetimeDB.Types\".to_string());\n        let module_name = command_config.get_one::<String>(\"unreal_module_name\")?;\n        let module_prefix = command_config.get_one::<String>(\"module_prefix\")?;\n        let build_options = command_config\n            .get_one::<String>(\"build_options\")?\n            .unwrap_or_else(String::new);\n        let dotnet_version = if command_config.is_from_cli(\"dotnet_version\") {\n            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,","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/generate.rs#L327-L363","documentation":"Unreal C++ binding generation emits a plugin into an Unreal Engine project, so generate must know the directory containing your `.uproject` file. When the resolved language is `unrealcpp` and neither the `--uproject-dir` flag nor an `uproject-dir` value in spacetime.json is present, the CLI rejects the invocation before doing any work. This is a deliberate pre-flight check so the more specific Unreal errors surface before generic path checks.","triggerScenarios":"`spacetime generate --lang unrealcpp` with no `--uproject-dir`; an unrealcpp target in spacetime.json that omits `uproject-dir`.","commonSituations":"Running generate from the server module directory instead of the UE project root; CI scripts copied from rust/typescript invocations; newly switching an existing target to unrealcpp.","solutions":["Pass `--uproject-dir /path/to/MyProject` pointing at the folder that contains MyProject.uproject","Add `\"uproject-dir\": \"...\"` to the unrealcpp target in spacetime.json so the flag isn't needed every run","Verify the directory actually contains a .uproject file"],"exampleFix":"# before\nspacetime generate --lang unrealcpp\n\n# after\nspacetime generate --lang unrealcpp --uproject-dir ~/Projects/MyGame --unreal-module-name MyGame","handlingStrategy":"validation","validationCode":"# Guard an unrealcpp generate invocation:\nif [[ \"$LANG_ARG\" == \"unrealcpp\" ]]; then\n  [[ -n \"$UPROJECT_DIR\" ]] || { echo \"unrealcpp requires --uproject-dir\" >&2; exit 2; }\n  ls \"$UPROJECT_DIR\"/*.uproject >/dev/null 2>&1 \\\n    || { echo \"no .uproject file in $UPROJECT_DIR\" >&2; exit 2; }\nfi\nspacetime generate --lang \"$LANG_ARG\" --uproject-dir \"$UPROJECT_DIR\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Keep `uproject-dir` in the unrealcpp target of spacetime.json instead of relying on CLI flags","Run generate from the UE project root so relative uproject-dir paths stay stable","Treat missing --uproject-dir as a usage error caught in a wrapper script, not at runtime"],"tags":["unrealcpp","generate","uproject","missing-flag"],"backgroundTag":"missing-required-flag","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}