jdx/mise · error

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

Error message

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

What it means

Variant of the unsupported-guard-condition error raised when a cask's `run` guard object exists but has no `condition` key at all (or it is not a string). A guard without a condition is meaningless, so the library bails instead of guessing semantics.

Source

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

            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
        .get("path")
        .and_then(Value::as_str)
        .ok_or_else(|| eyre!("brew-cask:{}: unsupported {kind} {field} path", cask.token))?;
    let base = match object.get("base").and_then(Value::as_str) {
        Some("staged_path") => FlightPathBase::StagedPath,

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Add an explicit `condition` key to the guard: "on", "if_exists", or "unless_exists".
  2. If no guard is intended, delete the guard object entirely so the artifact runs unconditionally.
  3. Re-fetch the cask to rule out truncated/corrupted stanza JSON.
  4. Validate the cask stanza against Homebrew's cask DSL schema before installing.

Example fix

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

Strategy: validation

Validate before calling

function guardHasCondition(guard) {
  return typeof guard === "object" && guard !== null && typeof guard.condition === "string";
}

Try / catch

try {
  installCask(token);
} catch (e) {
  if (String(e).includes("run guard condition") && !String(e).includes("{}")) {
    // empty-value variant: guard missing condition key
    console.warn(`Cask ${token} guard is missing its condition; skipping`);
  } else throw e;
}

Prevention

When it happens

Trigger: Parsing a cask whose guard object omits `condition`, e.g. {"value":"macos"} or {"path":"...","base":"appdir"} with no `condition` string.

Common situations: Hand-edited or machine-generated cask JSON missing the condition key, casks truncated by a bad fetch/transform, or authors writing a guard expecting an implicit default condition.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/10418214f038adc4. Report an issue: GitHub.