{"record":{"id":"bf644ff18554fab8","repo":"charmbracelet/gum","slug":"unable-to-pick-selection-w","errorCode":null,"errorMessage":"unable to pick selection: %w","messagePattern":"unable to pick selection: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"choose/command.go","lineNumber":154,"sourceCode":"\t\titemStyle:         o.ItemStyle.ToLipgloss(),\n\t\tselectedItemStyle: o.SelectedItemStyle.ToLipgloss(),\n\t\tnumSelected:       currentSelected,\n\t\tshowHelp:          o.ShowHelp,\n\t\thelp:              help.New(),\n\t\tkeymap:            km,\n\t}\n\n\tctx, cancel := timeout.Context(o.Timeout)\n\tdefer cancel()\n\n\t// Disable Keybindings since we will control it ourselves.\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(\"unable to pick selection: %w\", err)\n\t}\n\tm = tm.(model)\n\tif !m.submitted {\n\t\treturn errors.New(\"nothing selected\")\n\t}\n\tif o.Ordered && o.Limit > 1 {\n\t\tsort.Slice(m.items, func(i, j int) bool {\n\t\t\treturn m.items[i].order < m.items[j].order\n\t\t})\n\t}\n\n\tvar out []string\n\tfor _, item := range m.items {\n\t\tif item.selected {\n\t\t\tout = append(out, options[item.text])\n\t\t}\n\t}\n\ttty.Println(strings.Join(out, o.OutputDelimiter))","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/charmbracelet/gum/blob/4d089f95507708a71f64dacfe7ca513219dd5267/choose/command.go#L136-L172","documentation":"This wraps any error returned by the bubbletea program that renders the choose picker. It indicates the interactive UI itself failed to run or crashed, distinct from the user declining to select.","triggerScenarios":"tea.NewProgram(m, tea.WithOutput(os.Stderr), tea.WithContext(ctx)).Run() returns a non-nil err — e.g. context cancelled, output device not a terminal/inaccessible, or bubbletea internal failure.","commonSituations":"Context deadline exceeded from timeout.Context; running in a non-TTY environment (CI, no controlling terminal); stderr redirected to a closed pipe.","solutions":["Check the wrapped cause (%w) — often context cancellation or TTY issues","Run gum in a real terminal / allocate a TTY (e.g. `script -qec` in CI)","Retry or fall back to non-interactive mode if the environment cannot host a TUI"],"exampleFix":"// before\nCI: gum choose a b  # unable to pick selection: not a terminal\n// after\nscript -qec 'gum choose a b' /dev/null","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"if ! choice=$(gum choose a b c 2>err.log); then\n  grep -q 'unable to pick selection' <<<\"$(cat err.log)\" && echo 'TUI failed; check TTY/context'\nfi","preventionTips":["Run gum only where a real TTY is available","In CI use `script -qec` or a pseudo-tty","Check timeout/context settings that cancel the program"],"tags":["cli","gum","bubbletea","tty"],"backgroundTag":"tui-program-failed","analyzedSha":"4d089f95507708a71f64dacfe7ca513219dd5267","analyzedAt":"2026-08-31T18:45:06.436Z","schemaVersion":2},"datasetVersion":"2026-08-31T19:17:28.585Z"}