{"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":384,"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":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/clockworklabs/SpacetimeDB/blob/eddf9f5014579a50d4b67630e28b6e15cad9c4af/crates/cli/src/subcommands/generate.rs#L366-L402","documentation":"When resolving the output directory for a generate run, the CLI tries four sources in order: --out-dir, --uproject-dir, then a per-language default (default_out_dir_for_language: 'src/module_bindings' for Rust/TypeScript, 'module_bindings' for C#, and None for UnrealCpp). If all are exhausted — only possible for a language with no default, i.e. unrealcpp — the run is rejected with 'Either --out-dir or --uproject-dir is required'. Note the uproject_dir lookup flattens resolution errors with .ok(), so an unresolvable uproject-dir path is silently treated as absent.","triggerScenarios":"`spacetime generate --lang unrealcpp` with neither --out-dir nor --uproject-dir (typical when error 345 was bypassed via config-supplied uproject-dir that failed to resolve, or when generating unrealcpp from a spacetime.json entry lacking both keys).","commonSituations":"Non-interactive/CI generation for unrealcpp where the operator assumed a default output folder exists; spacetime.json generate entries copied from a Rust project (which never need out-dir because of the default) and switched to unrealcpp; a relative uproject-dir in config that fails to resolve against config_dir and is dropped by .ok().flatten().","solutions":["Pass --out-dir explicitly: `spacetime generate --lang unrealcpp --out-dir ./Generated`","Or pass --uproject-dir, which doubles as the output location for unrealcpp","For config-driven runs, add a resolvable `out-dir` (absolute, or relative to the spacetime.json directory) to the generate entry"],"exampleFix":"# before\nspacetime generate --lang unrealcpp --bin-path module.wasm\n# after\nspacetime generate --lang unrealcpp --bin-path module.wasm --out-dir ~/Projects/MyGame/Plugins/SpacetimeDB/Source\n\n# spacetime.json generate entry — after\n# { \"language\": \"unrealcpp\", \"bin-path\": \"target/wasm32-unknown-unknown/release/module.wasm\",\n#   \"out-dir\": \"../MyGame/Plugins/SpacetimeDB/Source\" }","handlingStrategy":"validation","validationCode":"# unrealcpp has NO default out dir — require one explicitly:\n: \"${OUT_DIR:?unrealcpp needs --out-dir or --uproject-dir}\"\nspacetime generate --lang unrealcpp --out-dir \"$OUT_DIR\" \"$@\"","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never assume a default output folder for unrealcpp; only rust/ts (src/module_bindings) and csharp (module_bindings) have defaults","Use absolute or config-relative out-dir paths in spacetime.json; a relative path that fails to resolve is silently dropped","Test generate configs in CI where a missing out-dir fails the build instead of a developer's machine"],"tags":["cli","generate","out-dir","unrealcpp","arguments","validation"],"backgroundTag":"output-directory-missing","analyzedSha":"eddf9f5014579a50d4b67630e28b6e15cad9c4af","analyzedAt":"2026-08-20T06:08:37.179Z","contentChangedAt":"2026-08-20T06:08:37.179Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}