{"record":{"id":"1a539c1bf45cf113","repo":"charmbracelet/gum","slug":"unable-to-confirm-w","errorCode":null,"errorMessage":"unable to confirm: %w","messagePattern":"unable to confirm: %w","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"confirm/command.go","lineNumber":54,"sourceCode":"\t\tshowOutput:       o.ShowOutput,\n\t\tconfirmation:     o.Default,\n\t\tdefaultSelection: o.Default,\n\t\tkeys:             defaultKeymap(o.Affirmative, o.Negative),\n\t\thelp:             help.New(),\n\t\tshowHelp:         o.ShowHelp,\n\t\tprompt:           o.Prompt,\n\t\tselectedStyle:    o.SelectedStyle.ToLipgloss(),\n\t\tunselectedStyle:  o.UnselectedStyle.ToLipgloss(),\n\t\tpromptStyle:      o.PromptStyle.ToLipgloss(),\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 && ctx.Err() != context.DeadlineExceeded {\n\t\treturn fmt.Errorf(\"unable to confirm: %w\", err)\n\t}\n\tm = tm.(model)\n\n\tif o.ShowOutput {\n\t\tconfirmationText := m.negative\n\t\tif m.confirmation {\n\t\t\tconfirmationText = m.affirmative\n\t\t}\n\t\tfmt.Println(m.prompt, confirmationText)\n\t}\n\n\tif m.confirmation {\n\t\treturn nil\n\t}\n\n\treturn exit.ErrExit(1)\n}\n","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/charmbracelet/gum/blob/4d089f95507708a71f64dacfe7ca513219dd5267/confirm/command.go#L36-L72","documentation":"gum confirm runs its yes/no prompt as a Bubble Tea program on stderr with the caller's context. If the program's Run returns an error AND the context's error is not `context.DeadlineExceeded`, Run wraps it as `unable to confirm: %w`. Deadline expiry is deliberately treated as a \"no\" answer rather than an error, so any error surfacing here is an unexpected TUI/TTY failure.","triggerScenarios":"Terminal initialization fails (no TTY, bad termios/raw-mode setup), an input/output write fails mid-prompt, or the Bubble Tea program errors for reasons other than the confirmation deadline expiring.","commonSituations":"Running `gum confirm` where stderr is redirected to a file or pipe; headless CI without a pty; unusual terminal types that break the renderer.","solutions":["Run inside a real terminal or wrap with a pty allocator (`script -qec 'gum confirm ...' /dev/null`).","Inspect the wrapped error to identify renderer vs. I/O cause; check TERM is set to a supported value.","Prefer `--timeout`/context deadlines for automation — those are handled gracefully as a negative answer.","Use `--default` behavior awareness: rely on timeout-as-no in scripts instead of failing hard."],"exampleFix":"// before\ngum confirm \"Deploy?\" > deploy.log 2>&1 // stderr not a TTY -> error\n// after\ngum confirm \"Deploy?\" // run interactively, or: script -qec 'gum confirm \"Deploy?\"' /dev/null","handlingStrategy":"validation","validationCode":"[ -t 2 ] || { echo \"gum confirm needs a TTY on stderr\" >&2; exit 1; }","typeGuard":null,"tryCatchPattern":"if ! gum confirm \"Deploy?\"; then\n  rc=$?\n  echo \"not confirmed (rc=$rc)\" >&2\nfi","preventionTips":["Keep stderr attached to the terminal — gum confirm renders on stderr.","In CI, use --timeout or --default instead of relying on interaction.","Wrap with a pty allocator when output must be captured.","Verify TERM in minimal environments (docker exec, ssh without -t)."],"tags":["go","cli","tui","tty"],"backgroundTag":"tui-program-run-failed","analyzedSha":"4d089f95507708a71f64dacfe7ca513219dd5267","analyzedAt":"2026-08-31T18:45:06.436Z","schemaVersion":2},"datasetVersion":"2026-08-31T22:30:34.772Z"}