gitbutlerapp/gitbutler · error
Unknown theme preset
Error message
Unknown theme preset: {unknown} What it means
ThemePreset implements FromStr accepting only "dark" and "light" (case-insensitive, trimmed). Any other value — e.g. a `but config theme` value stored or typed incorrectly — produces this error naming the unrecognized preset.
Solutions
- Set the theme to `dark` or `light`, e.g. `but config theme dark`.
- Trim whitespace and check spelling if the value comes from a config file.
- If you want automatic detection, omit the setting so the terminal colors are detected instead of specifying an unsupported preset.
Example fix
// before but config theme system // after but config theme dark
Defensive patterns
Strategy: validation
Validate before calling
const t = (raw ?? '').trim().toLowerCase();
if (t !== 'dark' && t !== 'light') throw new Error(`theme must be "dark" or "light", got "${raw}"`); Type guard
function isThemePreset(s) { return ['dark','light'].includes(s.trim().toLowerCase()); } Try / catch
match raw.parse::<ThemePreset>() {
Ok(p) => apply(p),
Err(_) => { eprintln!("theme '{raw}' unsupported; using dark"); apply(ThemePreset::Dark); }
} Prevention
- Only store dark/light in config files and scripts.
- Trim and lowercase user input before passing preset values.
- Omit the setting to let the CLI auto-detect from terminal colors.
When it happens
Trigger: Setting the theme via CLI config or environment to a value other than dark/light, such as `system`, `auto`, `solarized`, or a misspelling.
Common situations: Users copying theme names from other tools (VS Code themes); config files migrated from older CLI versions with different preset names; typos like "daark".
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Could not find range from
- Local AI configuration requires running inside a git…
- No target branch is configured and none could be inferred…
- Pass either --api-key or --api-key-env, not both
- with --key-option bring-your-own requires --api-key or…
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/16fa1ce0d02c0a0a.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but/src/theme.rs:234
/// Identifiers for the theme presets.
#[derive(Debug, PartialEq, Eq, Clone)]
pub enum ThemePreset {
/// The dark preset.
Dark,
/// The light preset.
Light,
}
impl FromStr for ThemePreset {
type Err = anyhow::Error;
fn from_str(s: &str) -> Result<Self, Self::Err> {
let normalized = s.to_lowercase();
match normalized.trim() {
"dark" => Ok(ThemePreset::Dark),
"light" => Ok(ThemePreset::Light),
unknown => Err(anyhow::anyhow!("Unknown theme preset: {unknown}")),
}
}
}
/// Detect the theme preset from the terminal's foreground and background colors.
///
/// Returns `None` if the terminal does not support color queries or does not respond in time.
pub(crate) fn detect_terminal_preset() -> Option<ThemePreset> {
terminal_colorsaurus::theme_mode(terminal_colorsaurus::QueryOptions::default())
.ok()
.map(theme_preset_from_terminal_mode)
}
fn theme_preset_from_terminal_mode(mode: terminal_colorsaurus::ThemeMode) -> ThemePreset {
match mode {
terminal_colorsaurus::ThemeMode::Dark => ThemePreset::Dark,
terminal_colorsaurus::ThemeMode::Light => ThemePreset::Light,
}View on GitHub (pinned to 58e5313667)