clockworklabs/SpacetimeDB · error · anyhow::Error

--unreal-module-name is required for --lang unrealcpp

Error message

--unreal-module-name is required for --lang unrealcpp

What it means

Second of the two unrealcpp pre-flight validations in `spacetime generate`: the generated plugin code needs an Unreal module name to emit the correct BUILD.cs and API macros. After confirming --uproject-dir is present, the CLI checks module_name; if it is None (no --unreal-module-name flag, no `module-name` in config), generation stops here.

Solutions

  1. Pass the UE module name matching your game module: `--unreal-module-name MyGame`
  2. Or add `"module-name": "MyGame"` to the unrealcpp generate entry in spacetime.json
  3. Check the name matches a module declared in your .uproject/Source so generated BUILD.cs compiles

Example fix

# before
spacetime generate --lang unrealcpp --uproject-dir ~/Projects/MyGame
# after
spacetime generate --lang unrealcpp --uproject-dir ~/Projects/MyGame --unreal-module-name MyGame
Defensive patterns

Strategy: validation

Validate before calling

: "${MODULE_NAME:?--unreal-module-name required for unrealcpp}"
spacetime generate --lang unrealcpp --uproject-dir "$UPROJECT_DIR" --unreal-module-name "$MODULE_NAME"

Prevention

When it happens

Trigger: Running `spacetime generate --lang unrealcpp --uproject-dir <dir>` without `--unreal-module-name` and without a module-name key in the generate config entry. Always fires after the uproject-dir check passes, i.e. you will only see it once error 345 is fixed.

Common situations: Iteratively fixing unrealcpp args — adding --uproject-dir then hitting this next; assuming the module name is inferred from the .uproject file (it is not, at this validation point); config entries migrated from csharp generation that use a different key name.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of clockworklabs/SpacetimeDB@eddf9f5014 (2026-08-20). Data as JSON: /api/errors/ab97026fa7544044. Report an issue: GitHub.

Appendix: source

Thrown at crates/cli/src/subcommands/generate.rs:347

        let module_name = command_config.get_one::<String>("unreal_module_name")?;
        let module_prefix = command_config.get_one::<String>("module_prefix")?;
        let build_options = command_config
            .get_one::<String>("build_options")?
            .unwrap_or_else(String::new);
        let dotnet_version = if command_config.is_from_cli("dotnet_version") {
            command_config.get_one::<u8>("dotnet_version")?
        } else {
            let dotnet_version = command_config.get_one::<String>("dotnet_version")?;
            parse_optional_dotnet_version(dotnet_version.as_deref())?
        };

        // Validate Unreal-specific args first to preserve focused errors for this mode.
        if requested_lang == Some(Language::UnrealCpp) {
            if command_config.get_one::<PathBuf>("uproject_dir")?.is_none() {
                return Err(anyhow::anyhow!("--uproject-dir is required for --lang unrealcpp"));
            }
            if module_name.is_none() {
                return Err(anyhow::anyhow!("--unreal-module-name is required for --lang unrealcpp"));
            }
        }

        // Validate module source path for source-based generation.
        if wasm_file.is_none() && js_file.is_none() && !project_path.is_dir() {
            anyhow::bail!(
                "Could not find module source at '{}'. \
                 If this is not correct, pass --module-path or add module-path in spacetime.json. \
                 You can also pass --bin-path/--js-path to generate without building from source.",
                project_path.display()
            );
        }

        let lang = match requested_lang {
            Some(lang) => lang,
            None => {
                let client_project_dir = config_dir.unwrap_or_else(|| Path::new("."));
                let detected = detect_default_language(client_project_dir)?;

View on GitHub (pinned to eddf9f5014)