commaai/openpilot · error

error: unexpected argument %s

Error message

error: unexpected argument %s

What it means

Printed by cabana's parseArgs for a non-option positional argument when the route has already been set — cabana accepts exactly one positional (the route). The second bare argument fails on the `a[0] == '-'` chain's final else; usage is printed and the process exits 1.

Source

Thrown at openpilot/tools/cabana/cabana.cc:119

      fprintf(stderr, "error: --socketcan is only supported on Linux\n");
      return 1;
#endif
    } else if (std::strcmp(a, "--zmq") == 0) {
      if (!takeValue(argc, argv, i, args.zmq)) return 1;
    } else if (std::strcmp(a, "--data_dir") == 0) {
      if (!takeValue(argc, argv, i, args.data_dir)) return 1;
    } else if (std::strcmp(a, "--no-vipc") == 0) {
      args.no_vipc = true;
    } else if (std::strcmp(a, "--dbc") == 0) {
      if (!takeValue(argc, argv, i, args.dbc)) return 1;
    } else if (a[0] == '-') {
      fprintf(stderr, "error: unknown option %s\n", a);
      printUsage(argv[0]);
      return 1;
    } else if (args.route.empty()) {
      args.route = a;
    } else {
      fprintf(stderr, "error: unexpected argument %s\n", a);
      printUsage(argv[0]);
      return 1;
    }
  }
  ok = true;
  return 0;
}

}  // namespace

int main(int argc, char *argv[]) {
  QCoreApplication::setApplicationName("Cabana");
  initApp(argc, argv, false);
  QApplication app(argc, argv);
  app.setApplicationDisplayName("Cabana");
  //app.setWindowIcon(QIcon(":cabana-icon.png"));  // TODO: do this in imgui

  UnixSignalHandler signalHandler;

View on GitHub (pinned to 516ec1e682)

Solutions

  1. Quote the route: cabana "abcdef--/2" so it stays one argument.
  2. Pass only one route per invocation; run cabana again for the next route.
  3. Remove stray trailing arguments (accidentally pasted text, empty-but-split variables).

Example fix

# before
cabana my route --/2        # 'route --/2' -> unexpected argument

# after
cabana "my route --/2"
Defensive patterns

Strategy: validation

Validate before calling

positionals = [a for a in sys.argv[1:] if not a.startswith('-')]
if len(positionals) > 1:
    raise SystemExit('cabana takes exactly one route argument')
subprocess.run(['cabana', *sys.argv[1:]])

Prevention

When it happens

Trigger: Running `cabana ROUTE1 ROUTE2`, or an unquoted route string with spaces splitting into two argv entries (e.g. 'a b--/2'), or a trailing stray word after the route.

Common situations: Unquoted route names containing spaces or special shell characters, shell glob expansion producing multiple tokens, or attempts to open multiple routes at once which cabana does not support.

Related errors


AI-assisted analysis of commaai/openpilot@516ec1e682 (2026-08-15). Data as JSON: /api/errors/1ac2b2159254c080. Report an issue: GitHub.