{"record":{"id":"470b45023d6225e4","repo":"clockworklabs/SpacetimeDB","slug":"either-out-dir-or-uproject-dir-is-required","errorCode":null,"errorMessage":"Either --out-dir or --uproject-dir is required","messagePattern":"Either --out-dir or --uproject-dir is required","errorType":"validation","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/cli/src/subcommands/generate.rs","lineNumber":385,"sourceCode":"                println!(\n                    \"Detected client language '{}' from '{}'. If this is not correct, pass --lang or add a generate target in spacetime.json.\",\n                    language_cli_name(detected),\n                    client_project_dir.display()\n                );\n                detected\n            }\n        };\n\n        let out_dir = command_config\n            .get_resolved_path(\"out_dir\", config_dir)?\n            .or_else(|| {\n                command_config\n                    .get_resolved_path(\"uproject_dir\", config_dir)\n                    .ok()\n                    .flatten()\n            })\n            .or_else(|| default_out_dir_for_language(lang).map(|p| config_dir.map(|d| d.join(&p)).unwrap_or(p)))\n            .ok_or_else(|| anyhow::anyhow!(\"Either --out-dir or --uproject-dir is required\"))?;\n\n        let include_private = command_config.get_one::<bool>(\"include_private\")?.unwrap_or(false);\n\n        runs.push(GenerateRunConfig {\n            project_path,\n            wasm_file,\n            js_file,\n            lang,\n            namespace,\n            module_name,\n            module_prefix,\n            build_options,\n            dotnet_version,\n            out_dir,\n            include_private,\n        });\n    }\n","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/524b4487d949b61a07d4f39c862d1290259dfd20/crates/cli/src/subcommands/generate.rs#L367-L403","documentation":"generate resolves the output directory through a chain: `out-dir`, then `uproject-dir`, then a per-language default (`src/module_bindings` for Rust/TypeScript, `module_bindings` for C#). UnrealCpp intentionally has no default because output belongs inside the UE project, so a run whose language resolves to unrealcpp with no usable `out-dir` or `uproject-dir` is rejected. In practice this fires when a configured uproject-dir exists as a value but fails path resolution, since a fully missing uproject-dir is caught earlier by the dedicated unrealcpp validation.","triggerScenarios":"An unrealcpp run where `uproject-dir` is set in spacetime.json/CLI but cannot be resolved to a path; an empty or malformed `out-dir` value together with an unresolvable `uproject-dir`; any future language registered without a default out-dir.","commonSituations":"spacetime.json entries with empty-string out-dir/uproject-dir values; paths that depend on a different working directory; configs moved between machines with different absolute paths.","solutions":["Pass `--out-dir <path>` explicitly","Fix the `uproject-dir` value in spacetime.json so it resolves from the directory generate runs in (prefer relative paths)","Remove empty-string `out-dir`/`uproject-dir` entries from spacetime.json so the fallback chain can work"],"exampleFix":"// spacetime.json — before (empty values defeat the fallback chain)\n{ \"generate\": { \"targets\": [ { \"database\": \"mydb\", \"lang\": \"unrealcpp\", \"uproject-dir\": \"\" } ] } }\n\n// spacetime.json — after\n{ \"generate\": { \"targets\": [ { \"database\": \"mydb\", \"lang\": \"unrealcpp\", \"uproject-dir\": \"../MyGame\" } ] } }","handlingStrategy":"validation","validationCode":"# Ensure an output location exists for languages without a default (unrealcpp):\nif [[ \"$LANG_ARG\" == \"unrealcpp\" && -z \"$OUT_DIR\" && -z \"$UPROJECT_DIR\" ]]; then\n  echo \"unrealcpp has no default out-dir — pass --out-dir or --uproject-dir\" >&2\n  exit 2\nfi\n# Also reject empty-string values in spacetime.json:\njq -e '.generate.targets[]? | select((.\"out-dir\" // \"x\") == \"\" or (.\"uproject-dir\" // \"x\") == \"\")' spacetime.json >/dev/null \\\n  && { echo \"empty out-dir/uproject-dir in spacetime.json\" >&2; exit 2; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never write empty-string out-dir/uproject-dir values into spacetime.json — omit the keys instead","Prefer relative paths in spacetime.json so resolution doesn't depend on the machine","Unreal targets always need a concrete output location; treat it as part of the target definition"],"tags":["generate","out-dir","unrealcpp","path-resolution"],"backgroundTag":"missing-output-directory","analyzedSha":"524b4487d949b61a07d4f39c862d1290259dfd20","analyzedAt":"2026-08-16T23:58:54.611Z","schemaVersion":2},"datasetVersion":"2026-08-17T04:17:16.089Z"}