{"record":{"id":"75a51508cf1c8013","repo":"jdx/mise","slug":"codesign-failed-for","errorCode":null,"errorMessage":"codesign failed for {}: {}","messagePattern":"codesign failed for (.+?): (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/packages/brew/relocate.rs","lineNumber":319,"sourceCode":"/// the kernel kills binaries whose signature doesn't match their contents.\npub(super) fn codesign(files: &[PathBuf]) -> Result<()> {\n    for file in files {\n        let res = crate::cmd::cmd(\n            \"/usr/bin/codesign\",\n            [\n                \"--sign\",\n                \"-\",\n                \"--force\",\n                \"--preserve-metadata=entitlements,requirements,flags,runtime\",\n                &file.to_string_lossy(),\n            ],\n        )\n        .stderr_capture()\n        .stdout_capture()\n        .unchecked()\n        .run()?;\n        if !res.status.success() {\n            bail!(\n                \"codesign failed for {}: {}\",\n                file.display(),\n                String::from_utf8_lossy(&res.stderr).trim()\n            );\n        }\n    }\n    Ok(())\n}\n\n#[cfg(test)]\npub(super) mod tests {\n    use super::*;\n    use std::io::{Cursor, Read, Write};\n    use std::os::unix::fs::PermissionsExt;\n\n    /// fixed macOS-style replacements so tests behave the same on all hosts\n    pub(in super::super) fn test_replacements() -> Vec<Replacement> {\n        vec![","sourceCodeStart":301,"sourceCodeEnd":337,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/packages/brew/relocate.rs#L301-L337","documentation":"mise runs the `codesign` binary (macOS code-signing tool) on binaries whose prefix paths were relocated during a Homebrew bottle install. When codesign exits non-zero, mise bails with this message and appends codesign's stderr. It means the relocated binary could not be re-signed, leaving it potentially unlaunchable on macOS.","triggerScenarios":"A bottle install relocated the prefix, then `codesign --force --sign - <file>` failed on that file — e.g. codesign not found, a corrupt/unreadable binary, a file codesign cannot sign (wrong Mach-O type), or keychain/signing-service failures.","commonSituations":"Partial or corrupted bottle extraction; signing a non-Mach-O file the formula listed; macOS security services (trustd) failing under heavy parallelism or in sandboxed/CI environments; PATH missing Xcode CLT so codesign is absent or broken.","solutions":["Re-run the install; transient codesign/trustd failures often succeed on retry","Verify codesign exists and works: run `codesign --version` (install/repair Xcode Command Line Tools with `xcode-select --install` if missing)","Check the failing binary with `file <path>`; if it is not a Mach-O binary, it should not require signing — report a mise bug if it does","Reinstall the formula cleanly (`brew cleanup` then retry via mise) to replace a corrupted binary"],"exampleFix":"// before: failing inside mise\nmise install node@22\n// after: ensure toolchain present, then retry\nxcode-select --install\nmise install node@22","handlingStrategy":"retry","validationCode":"command -v codesign >/dev/null 2>&1 || xcode-select --install\nfile \"$(brew --prefix)/opt/<formula>/bin/<binary>\" | grep -q Mach-O || echo 'not signable'","typeGuard":null,"tryCatchPattern":"match mise install output containing 'codesign failed for' => rerun `mise install` once; if it persists, inspect the named file with `codesign -dvv` and `file` before filing a bug","preventionTips":["Keep Xcode Command Line Tools installed and current on macOS","Avoid interrupting installs mid-relocation","Run `brew cleanup` after failed installs","Watch for macOS updates that invalidate signing services"],"tags":["macos","codesign","homebrew","subprocess"],"backgroundTag":"codesign-failed","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"}