{"record":{"id":"f55f58e48a846b6e","repo":"jdx/mise","slug":"brew-cask-pkgutil-receipt-check-for-pkg-id-is-f55f58","errorCode":null,"errorMessage":"brew-cask: pkgutil receipt check for '{pkg_id}' is only available on macOS","messagePattern":"brew-cask: pkgutil receipt check for '(.+?)' is only available on macOS","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/cask/state.rs","lineNumber":131,"sourceCode":"}\n\npub(super) fn homebrew_metadata_present(token: &str) -> Result<bool> {\n    let path = caskroom_token_dir(token).join(\".metadata\");\n    match path.symlink_metadata() {\n        Ok(_) => Ok(true),\n        Err(err) if err.kind() == std::io::ErrorKind::NotFound => Ok(false),\n        Err(err) => Err(err).wrap_err_with(|| {\n            format!(\n                \"brew-cask:{token}: failed to inspect Homebrew metadata at '{}'\",\n                path.display()\n            )\n        }),\n    }\n}\n\npub(super) fn pkg_id_installed(pkg_id: &str) -> Result<bool> {\n    #[cfg(not(target_os = \"macos\"))]\n    bail!(\"brew-cask: pkgutil receipt check for '{pkg_id}' is only available on macOS\");\n\n    #[cfg(target_os = \"macos\")]\n    // Homebrew's pkgutil metadata is a regular expression, not a literal ID.\n    // Match it with pkgutil itself to preserve its nonstandard regexp semantics.\n    // Like Homebrew, use the returned IDs rather than the exit status because a\n    // query with no matches may exit unsuccessfully.\n    let output = std::process::Command::new(\"pkgutil\")\n        .arg(format!(\"--pkgs={pkg_id}\"))\n        .stdin(std::process::Stdio::null())\n        .stderr(std::process::Stdio::null())\n        .output()?;\n    #[cfg(target_os = \"macos\")]\n    Ok(pkgutil_output_has_match(&output.stdout))\n}\n\n#[cfg(any(target_os = \"macos\", test))]\npub(super) fn pkgutil_output_has_match(output: &[u8]) -> bool {\n    output.iter().any(|byte| !byte.is_ascii_whitespace())","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/cask/state.rs#L113-L149","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Run this operation on macOS, where pkgutil exists.","Remove or guard the cask with pkg IDs in your mise package config when targeting non-macOS machines.","Use a Linux-native package source for that software instead of a brew cask."],"exampleFix":"// before: same cask list on all platforms\npackages = [\"brew-cask:foo-pkg-installer\"]\n\n// after: platform-conditional\n[settings.macos]\npackages = [\"brew-cask:foo-pkg-installer\"]","handlingStrategy":"type-guard","validationCode":"if !cfg!(target_os = \"macos\") {\n    // skip pkg-ID-backed casks on non-macOS hosts\n    return Ok(false);\n}","typeGuard":"fn supports_pkgutil() -> bool { cfg!(target_os = \"macos\") }","tryCatchPattern":"match pkg_id_installed(id) {\n    Err(e) if e.to_string().contains(\"only available on macOS\") => Ok(false),\n    other => other,\n}","preventionTips":["Keep cask packages with pkg installers macOS-only in your config.","Use platform-conditional package lists for multi-OS dotfiles/CI.","Prefer non-pkg casks or native packages on Linux."],"tags":["macos","pkgutil","platform","cask"],"backgroundTag":"unsupported-platform","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}