charmbracelet/glow · error

specified style does not exist: %s

Error message

specified style does not exist: %s

What it means

validateStyle runs when the requested style is not "auto" and not one of the built-in styles in styles.DefaultStyles. It expands the value with utils.ExpandPath (tilde expansion) and stats it; if stat returns fs.ErrNotExist, glow reports that the style does not exist. So this fires for a mistyped built-in style name or a custom style JSON path that is not present on disk.

Source

Thrown at main.go:158

	r, err := os.Open(arg)
	if err != nil {
		return nil, fmt.Errorf("unable to open file: %w", err)
	}
	u, err := filepath.Abs(arg)
	if err != nil {
		return nil, fmt.Errorf("unable to get absolute path: %w", err)
	}
	return &source{r, u}, nil
}

// validateStyle checks if the style is a default style, if not, checks that
// the custom style exists.
func validateStyle(style string) error {
	if style != "auto" && styles.DefaultStyles[style] == nil {
		style = utils.ExpandPath(style)
		if _, err := os.Stat(style); errors.Is(err, fs.ErrNotExist) {
			return fmt.Errorf("specified style does not exist: %s", style)
		} else if err != nil {
			return fmt.Errorf("unable to stat file: %w", err)
		}
	}
	return nil
}

func validateOptions(cmd *cobra.Command) error {
	// grab config values from Viper
	width = viper.GetUint("width")
	mouse = viper.GetBool("mouse")
	pager = viper.GetBool("pager")
	tui = viper.GetBool("tui")
	showAllFiles = viper.GetBool("all")
	preserveNewLines = viper.GetBool("preserveNewLines")
	showLineNumbers = viper.GetBool("showLineNumbers")

	if pager && tui {

View on GitHub (pinned to e3970c813d)

Solutions

  1. Check the spelling against the built-in style names glow/glamour ship (dark, light, notty, ...)
  2. For a custom style, verify the file exists: ls -l <stylepath> before running
  3. If using ~, confirm HOME points where you expect: echo $HOME
  4. Run from the directory containing the style file, or use an absolute path

Example fix

// before
glow -s dracul README.md   # typo: built-in style is 'dracula'

// after
glow -s dracula README.md
// or point at an existing custom style file:
glow -s /home/me/styles/dracula.json README.md
Defensive patterns

Strategy: validation

Validate before calling

func styleUsable(style string) bool {
	if style == "auto" || styles.DefaultStyles[style] != nil { return true }
	_, err := os.Stat(utils.ExpandPath(style))
	return err == nil
}

Prevention

When it happens

Trigger: glow -s mystyle.json with a typo'd or moved file; misspelling a built-in style name (e.g. dracul instead of dracula); HOME changed so ~ expands elsewhere; relative style path resolved from the wrong working directory.

Common situations: Typos in style names in scripts and CI, custom style files moved or deleted after config was written, HOME differing between environments (sudo, systemd) so tilde expansion lands somewhere else.

Related errors


AI-assisted analysis of charmbracelet/glow@e3970c813d (2026-08-15). Data as JSON: /api/errors/755b37301a69e632. Report an issue: GitHub.