{"record":{"id":"0c6e7bf273fcf2d4","repo":"sharkdp/bat","slug":"could-not-get-home-directory","errorCode":null,"errorMessage":"Could not get home directory","messagePattern":"Could not get home directory","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/theme.rs","lineNumber":293,"sourceCode":"}\n\n#[cfg(not(target_os = \"macos\"))]\nfn color_scheme_from_system() -> Option<ColorScheme> {\n    crate::bat_warning!(\n        \"Theme 'auto:system' is only supported on macOS, \\\n        using default.\"\n    );\n    None\n}\n\n#[cfg(target_os = \"macos\")]\nfn color_scheme_from_system() -> Option<ColorScheme> {\n    const PREFERENCES_FILE: &str = \"Library/Preferences/.GlobalPreferences.plist\";\n    const STYLE_KEY: &str = \"AppleInterfaceStyle\";\n\n    let preferences_file = std::env::home_dir()\n        .map(|home| home.join(PREFERENCES_FILE))\n        .expect(\"Could not get home directory\");\n\n    match plist::Value::from_file(preferences_file).map(|file| file.into_dictionary()) {\n        Ok(Some(preferences)) => match preferences.get(STYLE_KEY).and_then(|val| val.as_string()) {\n            Some(\"Dark\") => Some(ColorScheme::Dark),\n            // If the key does not exist, then light theme is currently in use.\n            Some(_) | None => Some(ColorScheme::Light),\n        },\n        // Unreachable, in theory. All macOS users have a home directory and preferences file setup.\n        Ok(None) | Err(_) => None,\n    }\n}\n\n#[cfg(test)]\nimpl ColorSchemeDetector for Option<ColorScheme> {\n    fn should_detect(&self) -> bool {\n        true\n    }\n","sourceCodeStart":275,"sourceCodeEnd":311,"githubUrl":"https://github.com/sharkdp/bat/blob/b671e53c2cd0177beb357cf6cb997ee4215c7155/src/theme.rs#L275-L311","documentation":"Error \"Could not get home directory\" thrown in sharkdp/bat.","triggerScenarios":"Thrown at src/theme.rs:293 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"b671e53c2cd0177beb357cf6cb997ee4215c7155","analyzedAt":"2026-08-16T08:15:54.742Z","schemaVersion":2},"datasetVersion":"2026-08-16T13:17:31.715Z"}