{"record":{"id":"1bdc1d53f57dcaeb","repo":"jdx/mise","slug":"failed-to-synchronize-macos-preference-domain-dom","errorCode":null,"errorMessage":"failed to synchronize macOS preference domain {domain}","messagePattern":"failed to synchronize macOS preference domain (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/defaults.rs","lineNumber":367,"sourceCode":"                value.as_CFTypeRef(),\n                application_id,\n                kCFPreferencesCurrentUser,\n                kCFPreferencesAnyHost,\n            );\n        }\n        Ok(())\n    }\n\n    fn synchronize(domain: &str) -> Result<()> {\n        let (_application, application_id) = application_id(domain);\n        unsafe {\n            if CFPreferencesSynchronize(\n                application_id,\n                kCFPreferencesCurrentUser,\n                kCFPreferencesAnyHost,\n            ) == 0\n            {\n                eyre::bail!(\"failed to synchronize macOS preference domain {domain}\");\n            }\n        }\n        Ok(())\n    }\n\n    pub(super) fn write_all(requests: &[DefaultsRequest]) -> Result<()> {\n        let mut domains = IndexSet::new();\n        for request in requests {\n            set(&request.domain, &request.key, &request.value)?;\n            domains.insert(request.domain.as_str());\n        }\n        for domain in domains {\n            synchronize(domain)?;\n        }\n        Ok(())\n    }\n\n    #[cfg(test)]","sourceCodeStart":349,"sourceCodeEnd":385,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/defaults.rs#L349-L385","documentation":"After writing macOS preference keys via CFPreferences (defaults), mise calls CFPreferencesSynchronize to flush the domain to disk. If synchronize returns 0 (failure), the preference domain could not be persisted; this instance is raised from the write path (synchronize, called by write_all).","triggerScenarios":"CFPreferencesSynchronize fails while flushing a defaults domain (kCFPreferencesCurrentUser, kCFPreferencesAnyHost) after writing keys, e.g. a malformed or unwritable plist backing the domain.","commonSituations":"Corrupt or wrong-permission ~/Library/Preferences/<domain>.plist; sandboxed or read-only HOME; domain managed by another process/MDM; disk-full filesystem on macOS.","solutions":["Check permissions and ownership of ~/Library/Preferences/<domain>.plist","Delete or repair the corrupt plist (e.g. `defaults delete <domain>` or remove the file) and retry","Verify HOME is writable and you are not in a sandbox blocking CFPreferences","Run `defaults read <domain>` to confirm the domain is accessible"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// preflight on macOS\nlet out = std::process::Command::new(\"defaults\").args([\"read\", domain]).output()?;\nif !out.status.success() { eprintln!(\"domain unreadable: {}\", domain); }","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"failed to synchronize\") => {\n        // repair plist permissions / delete corrupt plist, then retry\n    }\n    Err(e) => return Err(e),\n    Ok(_) => {}\n}","preventionTips":["Keep ~/Library/Preferences writable and owned by the current user","Avoid hand-editing plist files while tools are syncing","Repair disk/permission issues promptly (First Aid) on macOS"],"tags":["macos","defaults","plist","flush"],"backgroundTag":"file-write-failed","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}