charmbracelet/glow · error

cannot use both pager and tui

Error message

cannot use both pager and tui

What it means

validateOptions runs after flag parsing and Viper config binding, copying pager and tui from the merged config (flags + glow.yml). Because both modes take over output rendering in incompatible ways, having pager=true and tui=true simultaneously is rejected outright before any rendering starts. The values can come from --pager/--tui flags, the config file, or a mix of both.

Source

Thrown at main.go:177

		} 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 {
		return errors.New("cannot use both pager and tui")
	}

	// validate the glamour style
	style = viper.GetString("style")
	if err := validateStyle(style); err != nil {
		return err
	}

	isTerminal := term.IsTerminal(int(os.Stdout.Fd()))
	// We want to use a special no-TTY style, when stdout is not a terminal
	// and there was no specific style passed by arg
	if !isTerminal && !cmd.Flags().Changed("style") {
		style = "notty"
	}

	// Detect terminal width
	if !cmd.Flags().Changed("width") { //nolint:nestif
		if isTerminal && width == 0 {

View on GitHub (pinned to e3970c813d)

Solutions

  1. Use only one mode: drop either --tui or --pager from the command
  2. Edit the config file (glow config) and remove/turn off one of pager/tui
  3. Override on the CLI explicitly: glow --pager=false --tui

Example fix

# before (config has pager: true)
glow --tui README.md   # fails

# after
glow --pager=false --tui README.md
# or in glow.yml keep only one:
#   pager: true
#   tui: false
Defensive patterns

Strategy: validation

Validate before calling

# before launching glow, check the merged settings yourself
if grep -q '^pager: *true' ~/.config/glow/glow.yml 2>/dev/null; then
  TUI_FLAG=""
fi
glow $TUI_FLAG "$@"

Try / catch

if err := cmd.Execute(); err != nil {
	if strings.Contains(err.Error(), "cannot use both pager and tui") {
		// usage error: pick one mode and retry
		_ = cmd.Flags().Set("pager", "false")
		return cmd.Execute()
	}
	return err
}

Prevention

When it happens

Trigger: Passing both flags: glow --pager --tui; setting pager: true in ~/.config/glow/glow.yml and also passing --tui; a config file with both keys true; one mode enabled in config and the other via environment-bound flag default.

Common situations: Copy-pasted config files from dotfile repos that enable both options; incrementally adding --tui to a workflow that already sets pager in config; forgetting a previously edited glow.yml.

Related errors


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