{"record":{"id":"b38ac4ed2beda361","repo":"charmbracelet/glow","slug":"unable-to-run-tui-program-w","errorCode":null,"errorMessage":"unable to run tui program: %w","messagePattern":"unable to run tui program: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"main.go","lineNumber":368,"sourceCode":"\tif err != nil {\n\t\treturn fmt.Errorf(\"error parsing config: %v\", err)\n\t}\n\n\t// use style set in env, or auto if unset\n\tif err := validateStyle(cfg.GlamourStyle); err != nil {\n\t\tcfg.GlamourStyle = style\n\t}\n\n\tcfg.Path = path\n\tcfg.ShowAllFiles = showAllFiles\n\tcfg.ShowLineNumbers = showLineNumbers\n\tcfg.GlamourMaxWidth = width\n\tcfg.EnableMouse = mouse\n\tcfg.PreserveNewLines = preserveNewLines\n\n\t// Run Bubble Tea program\n\tif _, err := ui.NewProgram(cfg, content).Run(); err != nil {\n\t\treturn fmt.Errorf(\"unable to run tui program: %w\", err)\n\t}\n\n\treturn nil\n}\n\nfunc main() {\n\tcloser, err := setupLog()\n\tif err != nil {\n\t\tfmt.Println(err)\n\t\tos.Exit(1)\n\t}\n\tif err := rootCmd.Execute(); err != nil {\n\t\t_ = closer()\n\t\tos.Exit(1)\n\t}\n\t_ = closer()\n}\n","sourceCodeStart":350,"sourceCodeEnd":386,"githubUrl":"https://github.com/charmbracelet/glow/blob/e3970c813d93da1ea84edfca90c289d9afb82242/main.go#L350-L386","documentation":"The final step of the TUI path: ui.NewProgram(cfg, content).Run() starts a Bubble Tea program on the terminal. Errors come from the terminal I/O layer: no TTY available on stdin/stdout, TERM unset or set to a value without usable terminfo (e.g. dumb), failure opening /dev/tty, or renderer setup failing in non-interactive contexts. The underlying terminal error is wrapped with %w.","triggerScenarios":"Running glow's TUI with stdout piped or redirected (not a character device); TERM unset or TERM=dumb; ssh without -t; docker exec without -it; terminfo database missing or TERM misspelt (xterm256color).","commonSituations":"CI pipelines invoking the TUI, docker exec/kubectl exec sessions without -it, cron-invoked runs, minimal containers without terminfo installed, Windows terminals lacking ANSI support.","solutions":["Run in a real terminal: use ssh -t for remote, docker exec -it for containers","Set a valid TERM: export TERM=xterm-256color","Bypass the TUI when piping: glow README.md | cat (static render path)","Check the TERM spelling and that a terminfo entry exists: infocmp $TERM"],"exampleFix":"# before\nssh host \"glow\"              # no tty allocated\ndocker exec glow glow docs/readme.md\n\n# after\nssh -t host \"glow\"\ndocker exec -it glow glow docs/readme.md","handlingStrategy":"try-catch","validationCode":"func interactiveTerminal() bool {\n\tif term := os.Getenv(\"TERM\"); term == \"\" || term == \"dumb\" { return false }\n\tfi, err := os.Stdout.Stat()\n\tif err != nil { return false }\n\treturn fi.Mode()&os.ModeCharDevice != 0\n}","typeGuard":null,"tryCatchPattern":"if _, err := ui.NewProgram(cfg, content).Run(); err != nil {\n\tif !interactiveTerminal() {\n\t\t// no TTY: fall back to static rendering instead of failing\n\t\treturn renderStatic(content, w)\n\t}\n\treturn fmt.Errorf(\"unable to run tui program: %w\", err)\n}","preventionTips":["Check isatty and TERM before launching Bubble Tea programs","Always allocate a tty (-t / -it) for remote and container sessions","Provide a non-TUI output path in scripts that may run without a terminal"],"tags":["tui","terminal","bubbletea","environment"],"backgroundTag":null,"analyzedSha":"e3970c813d93da1ea84edfca90c289d9afb82242","analyzedAt":"2026-08-15T22:50:54.304Z","schemaVersion":2},"datasetVersion":"2026-08-16T03:17:38.424Z"}