jdx/mise · error
brew-cask: pkgutil receipt check for '{pkg_id}' is only avai
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 receipt exists. Homebrew only records pkg receipts on macOS, so calling this on any other platform is a programming error and mise bails immediately instead of returning a misleading result.
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 afd2eddd3a)
Solutions
- Only call pkg_ids_installed/pkg_id_installed on macOS (guard with cfg(target_os = "macos") or an OS check at the call site)
- Skip pkg-receipt validation for casks on non-macOS platforms
- If you need equivalent checks elsewhere, use the platform's own package receipt mechanism instead
Example fix
// before let installed = pkg_ids_installed(&receipt.pkg_ids)?; // after #[cfg(target_os = "macos")] let installed = pkg_ids_installed(&receipt.pkg_ids)?; #[cfg(not(target_os = "macos"))] let installed = false;
Defensive patterns
Strategy: validation
Validate before calling
#[cfg(target_os = "macos")] let installed = pkg_ids_installed(&receipt.pkg_ids)?; #[cfg(not(target_os = "macos"))] let installed = false;
Type guard
const fn pkg_receipts_supported() -> bool { cfg!(target_os = "macos") } Prevention
- Gate pkg-receipt checks behind cfg(target_os = "macos")
- Treat pkg_ids as macOS-only metadata in shared receipt structs
- Test cask flows on all target platforms in CI
When it happens
Trigger: pkg_id_installed is invoked on a non-macOS target (the #[cfg(not(target_os = "macos"))] arm), reached via pkg_ids_installed during cask state/receipt evaluation.
Common situations: Running mise cask management code paths on Linux/Windows CI; cross-platform code that unconditionally queries pkg receipts for a brew cask.
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
- mas cannot install a pinned version ('{p}')
- `defaults {display}` failed: {}
- `defaults {}` failed: {}
- only available on unix
- ditto failed copying {} to {}
AI-assisted analysis of jdx/mise@afd2eddd3a (2026-09-09).
Data as JSON: /api/errors/f55f58e48a846b6e.
Report an issue: GitHub.