JanDeDobbeleer/oh-my-posh · error

color name %s does not exist

Error message

color name %s does not exist

What it means

When converting a color specified by name to its ANSI code, getAnsiColorFromName looks the name up in the ansiColorCodes map. If the name is absent, it returns this error. It means the configured color string is not one of the recognized ANSI color names (or a valid hex was expected instead).

Source

Thrown at src/color/colors.go:430

	if colorInt, err := strconv.ParseInt(colorString, 10, 8); err == nil {
		c := color.C256(uint8(colorInt), isBackground)

		return Ansi(c.String())
	}

	return emptyColor
}

func (d *Defaults) Resolve(colorString Ansi) (Ansi, error) {
	return colorString, nil
}

func getAnsiColorFromName(colorValue Ansi, isBackground bool) (Ansi, error) {
	if colorCodes, found := ansiColorCodes[colorValue]; found {
		return colorCodes[generics.ToInt[int](isBackground)], nil
	}

	return "", fmt.Errorf("color name %s does not exist", colorValue)
}

func IsAnsiColorName(colorValue Ansi) bool {
	_, ok := ansiColorCodes[colorValue]
	return ok
}

// PaletteColors is the AnsiColors Decorator that uses the Palette to do named color
// lookups before ANSI color code generation.
type PaletteColors struct {
	ansiColors String
	palette    Palette
}

func (p *PaletteColors) ToAnsi(colorString Ansi, isBackground bool) Ansi {
	// a gradient string is not a palette key; guard it explicitly so it never round-trips
	// through palette resolution and reaches the next decorator untouched.
	if colorString.IsGradient() {

View on GitHub (pinned to 0976794618)

Solutions

  1. Use a documented color name (see oh-my-posh docs color list) or a hex value like '#ff0000'
  2. Verify spelling against IsAnsiColorName-recognized names (e.g. 'lightBlue', not 'brightblue')
  3. Run `oh-my-posh config` debug/render output to confirm which segment's color fails
  4. Validate the theme JSON against website/static/schema.json which enumerates allowed values

Example fix

// before (config.toml)
foreground = "brightblue"
// after
foreground = "lightBlue"
Defensive patterns

Strategy: validation

Validate before calling

if !IsAnsiColorName(foreground) && !strings.HasPrefix(foreground, "#") {
    return fmt.Errorf("color %q is neither a known ANSI color name nor a hex value", foreground)
}

Type guard

func isValidColor(v string) bool { return IsAnsiColorName(Ansi(v)) || strings.HasPrefix(v, "#") }

Try / catch

code, err := colors.ToAnsi(name, false)
if err != nil && strings.Contains(err.Error(), "does not exist") {
    code = defaultColor
}

Prevention

When it happens

Trigger: Setting a segment's foreground/background/template color to an unknown name in a theme config (e.g. 'brightblue' vs 'lightBlue'), then rendering the prompt so ToAnsi resolves the name.

Common situations: Hand-editing theme JSON/YAML/TOML with an invented color name, porting a theme from another prompt tool with different color vocabularies, or case/spacing mistakes in the color string.

Related errors


AI-assisted analysis of JanDeDobbeleer/oh-my-posh@0976794618 (2026-08-31). Data as JSON: /api/errors/0d6ce1710bf5d926. Report an issue: GitHub.