charmbracelet/glow · error

error parsing config: %v

Error message

error parsing config: %v

What it means

Before starting the TUI, glow parses the environment into ui.Config with caarlos0/env. The struct reads string fields from GOPATH, HOME and GLAMOUR_STYLE plus the bool GLOW_ENABLE_GLAMOUR (default true). This error means one of those variables could not be parsed into its field - practically, GLOW_ENABLE_GLAMOUR set to a value strconv.ParseBool rejects (anything other than 1/t/true/0/f/false, case variants). Note the format uses %v, so the underlying error chain is lost.

Source

Thrown at main.go:351

	case tui || cmd.Flags().Changed("tui"):
		path := ""
		if !isURL(src.URL) {
			path = src.URL
		}
		return runTUI(path, content)
	default:
		if _, err = fmt.Fprint(w, out); err != nil {
			return fmt.Errorf("unable to write to writer: %w", err)
		}
		return nil
	}
}

func runTUI(path string, content string) error {
	// Read environment to get debugging stuff
	cfg, err := env.ParseAs[ui.Config]()
	if err != nil {
		return fmt.Errorf("error parsing config: %v", err)
	}

	// use style set in env, or auto if unset
	if err := validateStyle(cfg.GlamourStyle); err != nil {
		cfg.GlamourStyle = style
	}

	cfg.Path = path
	cfg.ShowAllFiles = showAllFiles
	cfg.ShowLineNumbers = showLineNumbers
	cfg.GlamourMaxWidth = width
	cfg.EnableMouse = mouse
	cfg.PreserveNewLines = preserveNewLines

	// Run Bubble Tea program
	if _, err := ui.NewProgram(cfg, content).Run(); err != nil {
		return fmt.Errorf("unable to run tui program: %w", err)
	}

View on GitHub (pinned to e3970c813d)

Solutions

  1. Use a strict bool: export GLOW_ENABLE_GLAMOUR=false (or 0)
  2. Or unset the variable to keep the default (true): unset GLOW_ENABLE_GLAMOUR
  3. Check for stray characters: env | grep -i -E 'glow|glamour'

Example fix

# before
GLOW_ENABLE_GLAMOUR=off glow

# after
GLOW_ENABLE_GLAMOUR=false glow
Defensive patterns

Strategy: validation

Validate before calling

func boolEnvValid(names ...string) error {
	for _, n := range names {
		if v, ok := os.LookupEnv(n); ok && v != "" {
			if _, err := strconv.ParseBool(v); err != nil {
				return fmt.Errorf("%s=%q is not a valid bool", n, v)
			}
		}
	}
	return nil
}

Prevention

When it happens

Trigger: export GLOW_ENABLE_GLAMOUR=off/on/yes/no/enabled (invalid bools for ParseBool); values with stray whitespace or newlines; a typo'd variable name pattern that collides with the env tags.

Common situations: Users trying to disable glamour with GLOW_ENABLE_GLAMOUR=off instead of =false, dotfiles exporting loose truthy words, wrapper scripts setting boolean-looking env values.

Related errors


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