commaai/openpilot · error

error: --socketcan is only supported on Linux

Error message

error: --socketcan is only supported on Linux

What it means

Printed by cabana's parseArgs when --socketcan is passed on a non-Linux build (the handler body is empty unless __linux__ is defined, so the #else branch prints and returns 1). SocketCAN is a Linux kernel feature, so macOS/Windows builds of cabana cannot read from a CAN interface this way and exit with this error.

Source

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

      args.auto_source = true;
    } else if (std::strcmp(a, "--qcam") == 0) {
      args.qcam = true;
    } else if (std::strcmp(a, "--wide-road") == 0 || std::strcmp(a, "--ecam") == 0) {
      args.wide_road = true;
    } else if (std::strcmp(a, "--cabin") == 0 || std::strcmp(a, "--dcam") == 0) {
      args.cabin = true;
    } else if (std::strcmp(a, "--msgq") == 0) {
      args.msgq = true;
    } else if (std::strcmp(a, "--panda") == 0) {
      args.panda = true;
    } else if (std::strcmp(a, "--panda-serial") == 0) {
      if (!takeValue(argc, argv, i, args.panda_serial)) return 1;
      args.panda = true;
    } else if (std::strcmp(a, "--socketcan") == 0) {
      if (!takeValue(argc, argv, i, args.socketcan)) return 1;
#ifdef __linux__
#else
      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);

View on GitHub (pinned to 516ec1e682)

Solutions

  1. On the unsupported OS, use a Linux machine/container (WSL2 with usbip, Docker with --net=host) for live SocketCAN capture.
  2. Use alternatives that work cross-platform: --panda / --panda-serial for direct panda USB, --zmq to a remote agent, or replay a route.
  3. Verify with `ip link show can0` on the box that SocketCAN actually exists before blaming cabana.

Example fix

# before (macOS)
cabana --socketcan can0    # error: --socketcan is only supported on Linux

# after (macOS, live data via USB panda)
cabana --panda
Defensive patterns

Strategy: type-guard

Validate before calling

import sys, subprocess
if sys.platform == 'linux':
    subprocess.run(['cabana', '--socketcan', 'can0'])
else:
    subprocess.run(['cabana', '--panda'])  # cross-platform live capture

Type guard

def socketcan_supported() -> bool:
    import platform
    return platform.system() == 'Linux'

Prevention

When it happens

Trigger: Running `cabana --socketcan can0` on macOS or any non-Linux OS. The value is consumed by takeValue first, then the platform check kills the process with exit code 1.

Common situations: Developers on macOS replaying from hardware, or Windows users wanting live panda/CAN data; also WSL1 (no SocketCAN kernel support) even though it reports Linux.

Related errors


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