jdx/mise · error

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

Error message

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

What it means

A cask `run` guard's `condition` key must be one of `on`, `if_exists`, or `unless_exists`. This error is raised when the guard object specifies some other condition string. The library refuses to interpret guards it doesn't understand instead of executing artifacts under wrong conditions.

Source

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

            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!(
            "brew-cask:{}: unsupported {kind} run guard condition {}",
            cask.token,
            condition
        ),
        None => bail!(
            "brew-cask:{}: unsupported {kind} run guard condition",
            cask.token
        ),
    }
}

pub(super) fn parse_context_flight_path(
    cask: &Cask,
    kind: &str,
    field: &str,
    object: &serde_json::Map<String, Value>,
) -> Result<FlightPath> {
    let path = object

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Change the guard's `condition` to one of: "on", "if_exists", "unless_exists".
  2. If the intent is platform gating, use {"condition":"on","value":"macos"|"linux"}.
  3. For path-based gating, use if_exists/unless_exists with `path` and optionally `base`.
  4. Remove the guard if the artifact should run unconditionally; consider opening an upstream issue if a new Homebrew condition needs support.

Example fix

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

Strategy: validation

Validate before calling

const COND = new Set(["on", "if_exists", "unless_exists"]);
function hasKnownCondition(guard) {
  return typeof guard?.condition === "string" && COND.has(guard.condition);
}

Type guard

function isKnownGuard(g): g is { condition: "on" | "if_exists" | "unless_exists" } {
  return ["on", "if_exists", "unless_exists"].includes(g?.condition);
}

Try / catch

try {
  installCask(token);
} catch (e) {
  if (String(e).includes("run guard condition")) {
    console.warn(`Cask ${token} uses an unsupported guard condition; skipping guarded artifact`);
  } else throw e;
}

Prevention

When it happens

Trigger: Parsing a cask whose guard object has {"condition":"<other>", ...} where <other> is not `on`, `if_exists`, or `unless_exists` (e.g. `on_system`, `does_not_exist`, a quoted or renamed condition).

Common situations: Casks written against a newer Homebrew DSL version that added a new guard condition, custom-tap casks with hand-written conditions, or renamed/mistranslated condition keys in local cask edits.

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@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/fac3615b89b612f7. Report an issue: GitHub.