muesli/duf · error

unknown theme: %s

Error message

unknown theme: %s

What it means

loadTheme builds a fixed map of supported themes ("dark", "light", "ansi") and returns this error when the requested theme name is not a key in that map. It is a simple lookup failure: the theme string passed in (typically from a CLI flag or config) does not match any registered theme. The error message includes the offending theme name so the caller can see what was rejected.

Source

Thrown at themes.go:74

		colorBgYellow: env.Color("#fff4d0"),
		colorBgGreen:  env.Color("#e6ffe6"),
	}

	themes["ansi"] = Theme{
		colorRed:      env.Color("9"),
		colorYellow:   env.Color("11"),
		colorGreen:    env.Color("10"),
		colorBlue:     env.Color("12"),
		colorGray:     env.Color("7"),
		colorMagenta:  env.Color("13"),
		colorCyan:     env.Color("8"),
		colorBgRed:    env.Color("1"),
		colorBgYellow: env.Color("3"),
		colorBgGreen:  env.Color("2"),
	}

	if _, ok := themes[theme]; !ok {
		return Theme{}, fmt.Errorf("unknown theme: %s", theme)
	}

	return themes[theme], nil
}

View on GitHub (pinned to 4636deb4a7)

Solutions

  1. Run with one of the supported theme names: dark, light, or ansi
  2. Check the exact spelling and casing — the lookup is case-sensitive, so "Dark" fails
  3. If the theme came from a config file or env var, fix or remove that value
  4. List available themes from the tool's help output (or themes map in themes.go) and pick a valid one
  5. If a new theme is genuinely needed, add it to the themes map in loadTheme (or contribute it upstream)

Example fix

// before
loadTheme("Dark") // -> unknown theme: Dark
// after
loadTheme("dark") // valid: dark | light | ansi
Defensive patterns

Strategy: validation

Validate before calling

var validThemes = []string{"dark", "light", "ansi"}
func isValidTheme(name string) bool {
	for _, t := range validThemes {
		if t == name {
			return true
		}
	}
	return false
}
// before calling: if !isValidTheme(themeName) { themeName = "dark" }

Type guard

func knownTheme(name string) (string, bool) {
	switch name {
	case "dark", "light", "ansi":
		return name, true
	}
	return "", false
}

Try / catch

theme, err := loadTheme(name)
if err != nil {
	fmt.Fprintf(os.Stderr, "warning: %v; falling back to default theme %q\n", err, defaultThemeName())
	theme, err = loadTheme(defaultThemeName())
	if err != nil {
		fmt.Fprintln(os.Stderr, "fatal: default theme failed:", err)
		os.Exit(1)
	}
}

Prevention

When it happens

Trigger: Calling loadTheme(name) where name is not exactly "dark", "light", or "ansi" — e.g. loadTheme("solarized"), loadTheme("Dark") (case mismatch), loadTheme(""), or a misspelled name like "dakr". main reaches this whenever a user supplies an unlisted -theme/--theme flag value or a config file sets theme to an unknown name.

Common situations: A user passes --theme=monokai expecting extra built-in themes; a config file written for another tool carries a theme name this tool doesn't support; a typo or wrong casing ("Dark" vs "dark"); an empty theme value from an unset env var or blank CLI flag; version drift where a theme name was removed/renamed.

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


AI-assisted analysis of muesli/duf@4636deb4a7 (2026-09-06). Data as JSON: /api/errors/aea2babf10f7b3cc. Report an issue: GitHub.