{"record":{"id":"6bc5ab96453c9a57","repo":"charmbracelet/gum","slug":"failed-to-start-tea-program-w","errorCode":null,"errorMessage":"failed to start tea program: %w","messagePattern":"failed to start tea program: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"table/command.go","lineNumber":160,"sourceCode":"\n\tctx, cancel := timeout.Context(o.Timeout)\n\tdefer cancel()\n\n\tm := model{\n\t\ttable:     table,\n\t\tshowHelp:  o.ShowHelp,\n\t\thideCount: o.HideCount,\n\t\thelp:      help.New(),\n\t\tkeymap:    defaultKeymap(),\n\t\tpadding:   []int{top, right, bottom, left},\n\t}\n\ttm, err := tea.NewProgram(\n\t\tm,\n\t\ttea.WithOutput(os.Stderr),\n\t\ttea.WithContext(ctx),\n\t).Run()\n\tif err != nil {\n\t\treturn fmt.Errorf(\"failed to start tea program: %w\", err)\n\t}\n\n\tif tm == nil {\n\t\treturn fmt.Errorf(\"failed to get selection\")\n\t}\n\n\tm = tm.(model)\n\tif o.ReturnColumn > 0 && o.ReturnColumn <= len(m.selected) {\n\t\tif err = writer.Write([]string{m.selected[o.ReturnColumn-1]}); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write col %d of selected row: %w\", o.ReturnColumn, err)\n\t\t}\n\t} else {\n\t\tif err = writer.Write([]string(m.selected)); err != nil {\n\t\t\treturn fmt.Errorf(\"failed to write selected row: %w\", err)\n\t\t}\n\t}\n\n\twriter.Flush()","sourceCodeStart":142,"sourceCodeEnd":178,"githubUrl":"https://github.com/charmbracelet/gum/blob/4d089f95507708a71f64dacfe7ca513219dd5267/table/command.go#L142-L178","documentation":"gum table could not start its Bubble Tea (tea.Program) interactive UI. The underlying tea error (terminal incompatibility, context cancellation, output setup failure) is wrapped with %w. Without the TUI, no selection can be presented.","triggerScenarios":"`tea.NewProgram(...).Run()` returns an error: terminal not TTY-capable, context cancelled before program starts, or output initialization to os.Stderr fails.","commonSituations":"Running gum table in CI/non-interactive shells without a TTY, cancelling the command (Ctrl-C with context propagation or parent killed), restricted environments where /dev/tty is unavailable.","solutions":["Run gum table in an interactive terminal session","Check that the parent context isn't cancelled before the program starts","Verify the environment exposes a usable TTY (not a stripped CI runner)","Inspect the wrapped cause (%w) for the specific tea failure and address it"],"exampleFix":"// before\nCI_JOB=1 ./script.sh  # gum table fails: no TTY\n// after\nif [ -t 0 ]; then ./script.sh; else gum table < data.csv --no-input 2>/dev/null || true; fi","handlingStrategy":"try-catch","validationCode":"[ -t 0 ] && [ -t 2 ] || { echo 'gum table requires a TTY'; exit 1; }","typeGuard":null,"tryCatchPattern":"if ! sel=$(gum table < data.csv 2>/dev/null); then\n  echo 'selection cancelled or TUI failed' >&2\n  exit 1\nfi","preventionTips":["Only run interactive gum commands in TTY sessions","Guard CI scripts with TTY checks","Check for TERM being set properly"],"tags":["tui","terminal","bubbletea"],"backgroundTag":"tui-program-start-failed","analyzedSha":"4d089f95507708a71f64dacfe7ca513219dd5267","analyzedAt":"2026-08-31T18:45:06.436Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}