jdx/mise · error

brew-cask: : unsupported run guard platform

Error message

brew-cask:{}: unsupported {kind} run guard platform {}

What it means

A flight guard in a cask artifact used the "on" condition with a "value" naming a platform the parser does not know. Only "macos" and "linux" are accepted platform values for guards. Unknown platform strings are rejected rather than silently evaluating to false.

Solutions

  1. Change the guard value to "macos" or "linux".
  2. If the intent was architecture gating, use a different guard/condition mechanism — this guard only supports OS platform.
  3. Remove the guard if the step should run unconditionally.

Example fix

// before
{"condition": "on", "value": "darwin"}
// after
{"condition": "on", "value": "macos"}
Defensive patterns

Strategy: validation

Validate before calling

function validateGuardPlatform(guard) {
  if (guard?.condition === "on" && !["macos", "linux"].includes(guard.value)) {
    throw new Error(`unsupported run guard platform: ${guard.value}`);
  }
}

Type guard

function isSupportedPlatformGuard(g) {
  return g?.condition === "on" && typeof g.value === "string"
    && ["macos", "linux"].includes(g.value);
}

Try / catch

try {
  parseFlightArtifact(caskJson);
} catch (err) {
  if (String(err).includes("run guard platform")) {
    console.error('Guard platform must be "macos" or "linux"');
  }
  throw err;
}

Prevention

When it happens

Trigger: parse_flight_guard (via parse_flight_guards) parses a guard like {"condition": "on", "value": "windows"} or {"condition": "on", "value": "arm64"}; any value other than "macos"/"linux" fails.

Common situations: Porting casks written for macOS-only Homebrew that guard on "intel"/"arm"/arch strings, typos like "darwin" or "MacOS", or attempting to guard on CPU architecture which this guard does not support.

Understand the failure class

Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/84fd41ff2528c48a. Report an issue: GitHub.

Appendix: source

Thrown at src/system/packages/brew/cask/artifacts.rs:1002

pub(super) fn parse_flight_guard(cask: &Cask, kind: &str, value: &Value) -> Result<FlightGuard> {
    let object = value.as_object().ok_or_else(|| {
        eyre!(
            "brew-cask:{}: unsupported {kind} run guard metadata format",
            cask.token
        )
    })?;
    reject_unsupported_flight_fields(
        cask,
        kind,
        "run guard",
        object,
        &["condition", "value", "base", "path", "id"],
    )?;
    match object.get("condition").and_then(Value::as_str) {
        Some("on") => match object.get("value").and_then(Value::as_str) {
            Some("macos") => Ok(FlightGuard::OnMacos),
            Some("linux") => Ok(FlightGuard::OnLinux),
            Some(value) => bail!(
                "brew-cask:{}: unsupported {kind} run guard platform {}",
                cask.token,
                value
            ),
            None => bail!(
                "brew-cask:{}: unsupported {kind} run guard platform",
                cask.token
            ),
        },
        Some(condition @ ("if_exists" | "unless_exists")) => {
            let path = parse_context_flight_path(cask, kind, "run guard", object)?;
            if condition == "if_exists" {
                Ok(FlightGuard::IfExists(path))
            } else {
                Ok(FlightGuard::UnlessExists(path))
            }
        }
        Some(condition) => bail!(

View on GitHub (pinned to 533346cc37)