{"record":{"id":"82d197d27be22305","repo":"plandex-ai/plandex","slug":"failed-to-open-keyboard-s","errorCode":null,"errorMessage":"failed to open keyboard: %s","messagePattern":"failed to open keyboard: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"app/cli/term/prompt.go","lineNumber":73,"sourceCode":"\treturn res, nil\n}\n\nfunc GetUserPasswordInput(msg string) (string, error) {\n\tdisableBracketedPaste()\n\tdefer enableBracketedPaste()\n\n\tres, err := prompt.New().Ask(msg).Input(\"\", input.WithEchoMode(input.EchoPassword))\n\n\tif err != nil && err.Error() == \"user quit prompt\" {\n\t\tos.Exit(0)\n\t}\n\n\treturn res, err\n}\n\nfunc GetUserKeyInput() (rune, keyboard.Key, error) {\n\tif err := keyboard.Open(); err != nil {\n\t\treturn 0, 0, fmt.Errorf(\"failed to open keyboard: %s\", err)\n\t}\n\tdefer func() {\n\t\t_ = keyboard.Close()\n\t}()\n\n\tchar, key, err := keyboard.GetKey()\n\tif err != nil {\n\t\treturn 0, 0, fmt.Errorf(\"failed to read keypress: %s\", err)\n\t}\n\n\treturn char, key, nil\n}\n\nfunc ConfirmYesNo(fmtStr string, fmtArgs ...interface{}) (bool, error) {\n\tcolor.New(ColorHiMagenta, color.Bold).Printf(fmtStr+\" (y)es | (n)o\", fmtArgs...)\n\tcolor.New(ColorHiMagenta, color.Bold).Print(\"> \")\n\n\tchar, key, err := GetUserKeyInput()","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/plandex-ai/plandex/blob/e2d772072efadbe41d2946d97d79be55532dbab5/app/cli/term/prompt.go#L55-L91","documentation":"GetUserKeyInput wraps failures from the eiannone/keyboard library when putting the terminal into raw mode (keyboard.Open). Without raw mode the library cannot read single keystrokes, so confirm-style prompts cannot function.","triggerScenarios":"keyboard.Open() fails: stdin is not a TTY, the terminal can't be switched to raw mode (restricted environment, Windows console without cgo build of the lib, unsupported terminal), or the device file can't be opened.","commonSituations":"Running commands under piped stdin in CI, inside some IDE terminals or Windows shells lacking console support, or in sandboxed/container environments without a TTY.","solutions":["Run the command in a standard interactive terminal (xterm, iTerm, Windows Terminal)","Ensure stdin is a real TTY, not a pipe or /dev/null","On Windows, use a terminal that supports console input or a build with proper console support","Avoid running confirm-prompt commands under non-interactive automation; use flags that skip prompts"],"exampleFix":"// before\nprintf \"n\\n\" | plandex apply\n// after\nplandex apply --yes   # or run interactively and press y/n","handlingStrategy":"fallback","validationCode":"fi, _ := os.Stdin.Stat()\nttyOK := (fi.Mode() & os.ModeCharDevice) != 0 // if false, keyboard.Open will likely fail","typeGuard":null,"tryCatchPattern":"char, key, err := term.GetUserKeyInput()\nif err != nil {\n    // fallback: read a full line from a buffered reader instead of raw keyboard\n    line, _ := bufio.NewReader(os.Stdin).ReadString('\\n')\n    key = normalizeToKey(line)\n}","preventionTips":["Avoid raw-keyboard prompts in CI/scripts; use flag-based answers","Use standard terminals (iTerm2, Windows Terminal, xterm)","Test commands with piped stdin locally to catch non-TTY paths early"],"tags":["go","keyboard","tty","terminal"],"backgroundTag":"keyboard-open-failed","analyzedSha":"e2d772072efadbe41d2946d97d79be55532dbab5","analyzedAt":"2026-09-05T20:56:53.631Z","contentChangedAt":"2026-09-05T20:56:53.631Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}