{"record":{"id":"59459536b6e30121","repo":"charmbracelet/glow","slug":"cannot-use-both-pager-and-tui","errorCode":null,"errorMessage":"cannot use both pager and tui","messagePattern":"cannot use both pager and tui","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"main.go","lineNumber":177,"sourceCode":"\t\t} else if err != nil {\n\t\t\treturn fmt.Errorf(\"unable to stat file: %w\", err)\n\t\t}\n\t}\n\treturn nil\n}\n\nfunc validateOptions(cmd *cobra.Command) error {\n\t// grab config values from Viper\n\twidth = viper.GetUint(\"width\")\n\tmouse = viper.GetBool(\"mouse\")\n\tpager = viper.GetBool(\"pager\")\n\ttui = viper.GetBool(\"tui\")\n\tshowAllFiles = viper.GetBool(\"all\")\n\tpreserveNewLines = viper.GetBool(\"preserveNewLines\")\n\tshowLineNumbers = viper.GetBool(\"showLineNumbers\")\n\n\tif pager && tui {\n\t\treturn errors.New(\"cannot use both pager and tui\")\n\t}\n\n\t// validate the glamour style\n\tstyle = viper.GetString(\"style\")\n\tif err := validateStyle(style); err != nil {\n\t\treturn err\n\t}\n\n\tisTerminal := term.IsTerminal(int(os.Stdout.Fd()))\n\t// We want to use a special no-TTY style, when stdout is not a terminal\n\t// and there was no specific style passed by arg\n\tif !isTerminal && !cmd.Flags().Changed(\"style\") {\n\t\tstyle = \"notty\"\n\t}\n\n\t// Detect terminal width\n\tif !cmd.Flags().Changed(\"width\") { //nolint:nestif\n\t\tif isTerminal && width == 0 {","sourceCodeStart":159,"sourceCodeEnd":195,"githubUrl":"https://github.com/charmbracelet/glow/blob/e3970c813d93da1ea84edfca90c289d9afb82242/main.go#L159-L195","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Use only one mode: drop either --tui or --pager from the command","Edit the config file (glow config) and remove/turn off one of pager/tui","Override on the CLI explicitly: glow --pager=false --tui"],"exampleFix":"# before (config has pager: true)\nglow --tui README.md   # fails\n\n# after\nglow --pager=false --tui README.md\n# or in glow.yml keep only one:\n#   pager: true\n#   tui: false","handlingStrategy":"validation","validationCode":"# before launching glow, check the merged settings yourself\nif grep -q '^pager: *true' ~/.config/glow/glow.yml 2>/dev/null; then\n  TUI_FLAG=\"\"\nfi\nglow $TUI_FLAG \"$@\"","typeGuard":null,"tryCatchPattern":"if err := cmd.Execute(); err != nil {\n\tif strings.Contains(err.Error(), \"cannot use both pager and tui\") {\n\t\t// usage error: pick one mode and retry\n\t\t_ = cmd.Flags().Set(\"pager\", \"false\")\n\t\treturn cmd.Execute()\n\t}\n\treturn err\n}","preventionTips":["Keep only one of pager/tui enabled in glow.yml and override with --pager=false/--tui=false on the CLI","Review the config before adding a mode flag: glow config opens it in $EDITOR","Treat this message as a usage/config lint failure — fix the config, do not catch and ignore"],"tags":["config","flags","cli","validation"],"backgroundTag":null,"analyzedSha":"e3970c813d93da1ea84edfca90c289d9afb82242","analyzedAt":"2026-08-15T22:50:54.304Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}