stride3d/stride · error · OptionException

Unexpected arguments

Error message

Unexpected arguments [{0}]

What it means

Program.Main parses command-line options with an options parser (p.Parse). Any arguments that are not recognized declared options are returned as 'unexpectedArgs'; if any remain, Main throws OptionException naming the offending argument list. This is a strict fail-fast policy for the Stride debugger executable's CLI.

Solutions

  1. Remove or correct the unexpected arguments shown in the message (they are listed between the brackets).
  2. Use only documented options, e.g. --host <pipeName> and --wait-for-debugger-attach if available.
  3. Check the editor-generated launch command / profile for stale or duplicated arguments.
  4. Run Stride.Debugger with --help (or inspect Program.cs options setup) to list valid flags.

Example fix

// before
Stride.Debugger.exe --host pipeName --verbose extraArg

// after
Stride.Debugger.exe --host pipeName
Defensive patterns

Strategy: validation

Validate before calling

// Validate the command line before launching
def launch(debuggerPath, args):
    allowed = {'--host', '--wait-debugger-attach'}
    unknown = {a for a in args if a.startswith('--') and a not in allowed}
    assert not unknown, f"Unexpected debugger args: {unknown}"

Prevention

When it happens

Trigger: Launching Stride.Debugger.exe with extra/misspelled command-line tokens, e.g. a typo like --hos instead of --host, or a stray positional argument; p.Parse returns them as unexpected and Main throws at Program.cs:50.

Common situations: Hand-editing the editor's debugger launch command; IDE launch profiles with stale arguments; scripts passing quoted paths incorrectly so they split into extra tokens; upgrading Stride where an old option was removed.

Understand the failure class

Background: "Unknown argument", "Invalid value", and "must be one of": invalid CLI argument errors explained — this error's family across 35 libraries.

Related errors


AI-assisted analysis of stride3d/stride@96fad776d2 (2026-09-14). Data as JSON: /api/errors/319c33154c34396e. Report an issue: GitHub.

Appendix: source

Thrown at sources/engine/Stride.Debugger/Program.cs:50

                    "{0}.{1}.{2}",
                    typeof(Program).Assembly.GetName().Version.Major,
                    typeof(Program).Assembly.GetName().Version.Minor,
                    typeof(Program).Assembly.GetName().Version.Build) + string.Empty,
                string.Format("Usage: {0} --host=[hostpipe]", exeName),
                string.Empty,
                "=== Options ===",
                string.Empty,
                { "h|help", "Show this message and exit", v => showHelp = v != null },
                { "host=", "Host pipe", v => hostPipe = v },
                { "wait-debugger-attach", "Process will wait for a debuggger to attach, for 5 seconds", v => waitDebuggerAttach = true },
            };

            try
            {
                var unexpectedArgs = p.Parse(args);
                if (unexpectedArgs.Any())
                {
                    throw new OptionException("Unexpected arguments [{0}]".ToFormat(string.Join(", ", unexpectedArgs)), "args");
                }

                if (waitDebuggerAttach)
                {
                    // Wait for 2 second max
                    for (int i = 0; i < 500; ++i)
                    {
                        if (System.Diagnostics.Debugger.IsAttached)
                        {
                            break;
                        }

                        Thread.Sleep(10);
                    }
                }

                if (hostPipe == null)
                {

View on GitHub (pinned to 96fad776d2)