cli: gh auth login: could not prompt: The handle is invalid.
Describe the bug
I downloaded gh via chocolatey and tried to login with GitHub, but looks like its not working. When it asks for the prompt, it stops telling: could not prompt: The handle is invalid.
Output of gh --version:
gh version 1.0.0 (2020-09-16)
https://github.com/cli/cli/releases/tag/v1.0.0
Steps to reproduce the behavior
- Type this
gh auth login - View the output:
? What account do you want to log into? [Use arrows to move, type to filter]
>GitHub.com
GitHub Enterprise Server
- See error:
could not prompt: The handle is invalid.
Expected vs actual behavior
Expected: To have me use the arrow keys to select the hostname + the way to login, Personal Access Token or Web Actual: Stops executing with err code 1: could not prompt: The handle is invalid.
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 2
- Comments: 18 (9 by maintainers)
Hey all! I found out a solution, but for Git Bash! Instead of running
<command>, runwinpty <command>[.exe|.cmd]. In this case,winpty gh.exe auth loginOr, if you are too lazy đ , runecho "alias <command (without options)>=\"winpty <command (without options)>\"" >> ~/.bashrcIn this case: echo"alias gh=\"winpty gh.exe\"" >> ~/.bashrcReference(though not related): Vue.js CLI Docs (see warning)
Iâm unable to navigate the menus. I get the following error when I use the arrow keys.
Unexpected Escape Sequence: ['\x1b' 'O']macOS, zsh, iTerm2, tmux
When I installed Git for Windows, I chose not to use mintty but the regular old conhost.exe that comes with Windows
@alannt777 Youâre right. This only ever happens on emulators that donât support interactive Command line interfaces, like ConEmu(possibly via Cmder), MinTTY (Possibly via Git Bash, Cygwin and many others). While installing Git for Windows, there is an option that says, âEnable experimental support for pseudo terminalsâ or something similar. If we check that option, the interactive CLIs work. But as it mentions, âthis option is experimentalâ
I eventually found the root of this secondary issue.
gh auth login --hostname github.com --webworks (lowercase âgithub.comâ), butgh auth login --hostname GitHub.com --web(mixed case âGitHub.comâ) does not work. Both commands report success, but the results from the mixed-case version are not successfully leveraged by later commands. This is regardless of the terminal/shell being used.This issue is not confined to the
gh auth login. It also happens when trying to rungh repo create.Running the following command:
$ gh repo create mzzmjd/created-via-cli --internalReturns the error message:
? This will create 'mzzmjd/created-via-cli' in your current directory. Continue? (Y/n) The handle is invalid.@smw4 That seems like the same issue as https://github.com/cli/cli/issues/6147, would you mind adding your system details to that issue as we have been unable to reproduce it so far.
When I try your fix, I get the following error message, which Iâm having difficulty deciphering.
Iâm getting the exact same issue using git bash for Windows version 2.27.0.windows.1. I thought I might be able to work around it by avoiding the prompts via âgh auth login --hostname GitHub.com --webâ and I got successfully through the authentication steps, but it doesnât seem to successfully remember the authentication. When I then tried âgh pr create --fillâ I received âHTTP 401: This endpoint requires you to be authenticatedâŚâ.
I am using ZSH with MSYS2 Bash with ConEmuC64 with Cmder đ
Also, if I use this with Cmd, then directly from MSYS2 Shell, then bash.exe executable, then zsh.exe executable, it does work đź
I get the same error message using Git bash Version 2.28.0.windows.1
You donât get the option to move the selection: