jdx/mise · error

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

Error message

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

What it means

Thrown when a run/copy guard has a condition string mise does not implement. Recognized conditions are exactly "on" (platform), "if_exists", and "unless_exists" (path existence). Conditions like "if_running", "unless_changed", or "if" land in this arm and bail with the condition echoed.

Source

Thrown at src/system/packages/brew/cask.rs:5925

            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
        ),
    }
}

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 6f52dcdf99)

Solutions

  1. Express platform checks as {"condition": "on", "value": "macos"|"linux"}
  2. Express file checks as {"condition": "if_exists"|"unless_exists", "path": ..., "base": ...}
  3. If the guard cannot be expressed, remove it and update mise / report the cask token upstream

Example fix

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

Strategy: validation

Validate before calling

fn guard_condition_ok(g: &serde_json::Value) -> bool {
    matches!(g.get("condition").and_then(|c| c.as_str()), None | Some("on") | Some("if_exists") | Some("unless_exists"))
}

Type guard

fn is_supported_condition(v: &serde_json::Value) -> bool {
    v.as_str().map(|c| ["on", "if_exists", "unless_exists"].contains(&c)).unwrap_or(false)
}

Try / catch

match parse_flight_guard(&cask, kind, &guard) {
    Ok(g) => { /* proceed */ }
    Err(e) if e.to_string().contains("run guard condition") => {
        eprintln!("guard conditions are limited to on / if_exists / unless_exists");
    }
    Err(e) => return Err(e),
}

Prevention

When it happens

Trigger: {"guards": [{"condition": "if_running", "value": "com.apple.x"}]} on a run or copy step inside preflight_steps/postflight_steps.

Common situations: Porting Homebrew Ruby DSL concepts (only_if/unless_method, launchctl checks) that have no JSON equivalent; inventing conditions beyond the implemented trio; version skew with newer Homebrew metadata.

Related errors


AI-assisted analysis of jdx/mise@6f52dcdf99 (2026-08-22). Data as JSON: /api/errors/cc5ceefe590beafa. Report an issue: GitHub.