{"record":{"id":"b4b974088e4c9b09","repo":"jdx/mise","slug":"defaults-display-failed","errorCode":null,"errorMessage":"`defaults {display}` failed: {}","messagePattern":"`defaults (.+?)` failed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/defaults.rs","lineNumber":178,"sourceCode":"        let mut args = vec![\"write\".to_string(), req.domain.clone(), req.key.clone()];\n        args.extend(req.value.write_args());\n        // shell-quoted so the printed command is copy-pasteable even when a\n        // string value contains spaces\n        let display = shell_words::join(&args);\n        if dry_run {\n            miseprintln!(\"defaults {display}\");\n            continue;\n        }\n        debug!(\"$ defaults {display}\");\n        let output = tokio::process::Command::new(\"defaults\")\n            .args(&args)\n            .stdin(Stdio::null())\n            .stdout(Stdio::piped())\n            .stderr(Stdio::piped())\n            .output()\n            .await?;\n        if !output.status.success() {\n            eyre::bail!(\n                \"`defaults {display}` failed: {}\",\n                String::from_utf8_lossy(&output.stderr).trim()\n            );\n        }\n    }\n    Ok(())\n}\n\n/// `defaults read-type` + `defaults read` for one key. Returns\n/// `(type, raw value)`, or None when the key (or domain) does not exist —\n/// both commands exit non-zero for that, which is not an error here.\nasync fn read(domain: &str, key: &str) -> Result<Option<(String, String)>> {\n    let Some(read_type) = defaults_cmd(&[\"read-type\", domain, key]).await? else {\n        return Ok(None);\n    };\n    // \"Type is boolean\" -> \"boolean\"\n    let read_type = read_type\n        .strip_prefix(\"Type is \")","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/system/defaults.rs#L160-L196","documentation":"Applying [bootstrap.macos.defaults] entries runs 'defaults write <domain> <key> -<type> <value>' per key via 'mise bootstrap macos defaults apply' (or full 'mise bootstrap'); when the macOS defaults command exits non-zero, mise bails with the command rendered as 'defaults <domain> <key> = <value>' plus trimmed stderr. There is no missing-key exemption at write time — a failing write is always an error.","triggerScenarios":"defaults write failing: the domain/key is managed by an MDM configuration profile and read-only, cfprefsd is unavailable (headless SSH session with no GUI domain), the preferences plist is corrupt, or macOS refuses the type conversion for the key.","commonSituations":"Corporate Macs with managed preferences; running mise bootstrap over SSH before any GUI login; a plist corrupted after a crash or forced shutdown.","solutions":["Run the exact 'defaults write ...' line from the error manually to see macOS's own complaint","If the domain is MDM-managed, remove that key from [bootstrap.macos.defaults] — it cannot be set declaratively","For corrupt plists: quit the owning app, delete ~/Library/Preferences/<domain>.plist, and re-run bootstrap; for headless runs, bootstrap from a real GUI login session"],"exampleFix":"# before\n[bootstrap.macos.defaults.\"com.corp.managed\"]\nDisableThing = true\n\n# after — key is owned by an MDM profile, manage it out of band\n# (remove the entry from mise.toml entirely)","handlingStrategy":"try-catch","validationCode":"# preflight: probe writability of each configured domain\ndefaults write \"$DOMAIN\" __mise_probe -bool true && defaults delete \"$DOMAIN\" __mise_probe \\\n  || echo \"domain $DOMAIN not writable — remove it from [bootstrap.macos.defaults]\"","typeGuard":null,"tryCatchPattern":"Apply defaults per domain ('mise bootstrap macos defaults apply') in scripts and catch non-zero exits: print the failing 'defaults write' line from the log, classify MDM/permission errors as permanent (drop the key from config) and cfprefsd/headless errors as retryable once a GUI session exists.","preventionTips":["Do not declare MDM-managed keys in bootstrap defaults — check 'profiles status -type configurationProfile' first","Apply defaults from a logged-in GUI session, not raw SSH before first login","Layer config so managed hosts never see corporate-owned domains (mise.local.toml or environment-specific configs)"],"tags":["mise","macos","defaults","bootstrap","cfprefsd"],"backgroundTag":"macos-defaults-command-failed","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T15:18:49.778Z"}