jdx/mise · error

brew-cask:{}: unsupported {kind} sudo setting

Error message

brew-cask:{}: unsupported {kind} sudo setting

What it means

A flight step's `sudo` setting controls when a step runs with elevation: only three values are accepted — boolean `false`/absent (never), boolean `true` (always), and the string `"if_needed"`. Any other value triggers this bail in parse_flight_sudo.

Source

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

        }
        _ => bail!(
            "brew-cask:{}: unsupported {kind} step type {}",
            cask.token,
            step_type
        ),
    }
}

pub(super) fn parse_flight_sudo(
    cask: &Cask,
    kind: &str,
    value: Option<&Value>,
) -> Result<FlightSudo> {
    match value {
        None | Some(Value::Bool(false)) => Ok(FlightSudo::Never),
        Some(Value::Bool(true)) => Ok(FlightSudo::Always),
        Some(Value::String(value)) if value == "if_needed" => Ok(FlightSudo::IfNeeded),
        _ => bail!("brew-cask:{}: unsupported {kind} sudo setting", cask.token),
    }
}

pub(super) fn parse_flight_guards(
    cask: &Cask,
    kind: &str,
    value: Option<&Value>,
) -> Result<Vec<FlightGuard>> {
    value
        .map(|guards| {
            guards
                .as_array()
                .ok_or_else(|| {
                    eyre!(
                        "brew-cask:{}: unsupported {kind} guards metadata format",
                        cask.token
                    )
                })?

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Replace the value with `true` (always sudo), `false` (never), or the string `"if_needed"`.
  2. Remove the `sudo` key to use the default (never).
  3. When migrating from Homebrew, map :always -> true and omit other forms.

Example fix

// before
[[install.flight_steps]]
type = "symlink"
source = "bin/myapp"
target = "/usr/local/bin/myapp"
sudo = "always"
// after
[[install.flight_steps]]
type = "symlink"
source = "bin/myapp"
target = "/usr/local/bin/myapp"
sudo = true
Defensive patterns

Strategy: type-guard

Validate before calling

function validateSudo(step) {
  const ok = step.sudo === undefined || step.sudo === true || step.sudo === false || step.sudo === 'if_needed';
  if (!ok) throw new Error(`unsupported sudo setting: ${JSON.stringify(step.sudo)}`);
}

Type guard

const isValidSudo = (s) => s === undefined || typeof s === 'boolean' || s === 'if_needed';

Prevention

When it happens

Trigger: A cask sets `sudo = "always"`, `sudo = "auto"`, `sudo = 1`, or any non-accepted value on a Symlink (or other) flight step; FlightStep::Symlink parsing calls parse_flight_sudo which hits the catch-all arm.

Common situations: Porting Homebrew cask `sudo` DSL semantics with richer values; assuming string synonyms like "never" work; numeric booleans from generated config.

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/9335ee55398d775f. Report an issue: GitHub.