jdx/mise · error

brew-cask: pkgutil receipt check for

Error message

brew-cask: pkgutil receipt check for '{pkg_id}' is only available on macOS

What it means

pkg_id_installed checks macOS's pkgutil receipt database to see whether a cask's pkg installer received a package ID. pkgutil does not exist on Linux (or other non-macOS platforms), so the check is a compile-time macOS-only operation and calling it elsewhere is an unsupported-platform error by design.

Solutions

  1. Run this operation on macOS, where pkgutil exists.
  2. Remove or guard the cask with pkg IDs in your mise package config when targeting non-macOS machines.
  3. Use a Linux-native package source for that software instead of a brew cask.

Example fix

// before: same cask list on all platforms
packages = ["brew-cask:foo-pkg-installer"]

// after: platform-conditional
[settings.macos]
packages = ["brew-cask:foo-pkg-installer"]
Defensive patterns

Strategy: type-guard

Validate before calling

if !cfg!(target_os = "macos") {
    // skip pkg-ID-backed casks on non-macOS hosts
    return Ok(false);
}

Type guard

fn supports_pkgutil() -> bool { cfg!(target_os = "macos") }

Try / catch

match pkg_id_installed(id) {
    Err(e) if e.to_string().contains("only available on macOS") => Ok(false),
    other => other,
}

Prevention

When it happens

Trigger: pkg_id_installed(pkg_id) is compiled with #[cfg(not(target_os = "macos")] and unconditionally bails; it is reached via pkg_ids_installed when a cask receipt declares pkg IDs and the host is not macOS.

Common situations: Running mise's brew-cask package support on Linux (Homebrew on Linux supports casks poorly but some receipts still carry pkg IDs); cross-platform CI or dotfiles installing the same cask config on both platforms.

Understand the failure class

Background: "unsupported platform" / "not supported on this platform" errors: what they mean and how to fix them — this error's family across 47 libraries.

Related errors


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

Appendix: source

Thrown at src/system/packages/brew/cask/state.rs:131

}

pub(super) fn homebrew_metadata_present(token: &str) -> Result<bool> {
    let path = caskroom_token_dir(token).join(".metadata");
    match path.symlink_metadata() {
        Ok(_) => Ok(true),
        Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(false),
        Err(err) => Err(err).wrap_err_with(|| {
            format!(
                "brew-cask:{token}: failed to inspect Homebrew metadata at '{}'",
                path.display()
            )
        }),
    }
}

pub(super) fn pkg_id_installed(pkg_id: &str) -> Result<bool> {
    #[cfg(not(target_os = "macos"))]
    bail!("brew-cask: pkgutil receipt check for '{pkg_id}' is only available on macOS");

    #[cfg(target_os = "macos")]
    // Homebrew's pkgutil metadata is a regular expression, not a literal ID.
    // Match it with pkgutil itself to preserve its nonstandard regexp semantics.
    // Like Homebrew, use the returned IDs rather than the exit status because a
    // query with no matches may exit unsuccessfully.
    let output = std::process::Command::new("pkgutil")
        .arg(format!("--pkgs={pkg_id}"))
        .stdin(std::process::Stdio::null())
        .stderr(std::process::Stdio::null())
        .output()?;
    #[cfg(target_os = "macos")]
    Ok(pkgutil_output_has_match(&output.stdout))
}

#[cfg(any(target_os = "macos", test))]
pub(super) fn pkgutil_output_has_match(output: &[u8]) -> bool {
    output.iter().any(|byte| !byte.is_ascii_whitespace())

View on GitHub (pinned to 533346cc37)