{"record":{"id":"43d21676f5aa94eb","repo":"charmbracelet/gum","slug":"unable-to-pick-selection-w-43d216","errorCode":null,"errorMessage":"unable to pick selection: %w","messagePattern":"unable to pick selection: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"file/command.go","lineNumber":70,"sourceCode":"\t\tfilepicker:  fp,\n\t\tpadding:     []int{top, right, bottom, left},\n\t\tshowHelp:    o.ShowHelp,\n\t\thelp:        help.New(),\n\t\tkeymap:      defaultKeymap(),\n\t\theaderStyle: o.HeaderStyle.ToLipgloss(),\n\t\theader:      o.Header,\n\t}\n\n\tctx, cancel := timeout.Context(o.Timeout)\n\tdefer cancel()\n\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.selectedPath == \"\" {\n\t\treturn errors.New(\"no file selected\")\n\t}\n\n\tfmt.Println(m.selectedPath)\n\treturn nil\n}\n","sourceCodeStart":52,"sourceCodeEnd":80,"githubUrl":"https://github.com/charmbracelet/gum/blob/4d089f95507708a71f64dacfe7ca513219dd5267/file/command.go#L52-L80","documentation":"This wraps any error from the bubbletea program that runs the file picker. It indicates the interactive TUI failed to start or crashed, not that the user declined to pick a file.","triggerScenarios":"tea.NewProgram(m, tea.WithOutput(os.Stderr), tea.WithContext(ctx)).Run() returns non-nil err — context cancelled/timed out, no usable TTY on stderr, or bubbletea internal error.","commonSituations":"Timeout via timeout.Context expiring; CI environments without a TTY; stderr piped into a closed reader.","solutions":["Inspect the wrapped cause for context cancellation vs TTY problems","Run inside a real terminal or allocate one (e.g. `script -qec`) in CI","Extend the timeout or fall back to a non-interactive file listing"],"exampleFix":"// before\ngum file --timeout 1s  # unable to pick selection: context deadline exceeded\n// after\ngum file --timeout 30s","handlingStrategy":"try-catch","validationCode":"null","typeGuard":"null","tryCatchPattern":"if ! path=$(gum file --file 2>err.log); then\n  cat err.log >&2  # inspect wrapped cause: TTY vs context deadline\nfi","preventionTips":["Use generous timeouts; check context cancellation","Ensure stderr is a usable terminal","Allocate a pseudo-tty in CI pipelines"],"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"}