Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Git Bash errors with prompt_password_stdout or read_password on Windows #49

Closed
bochaco opened this issue Apr 6, 2020 · 7 comments
Closed

Comments

@bochaco
Copy link

bochaco commented Apr 6, 2020

I'm getting OS error 6 ("The handle is invalid") on Windows using Git Bash when calling prompt_password_stdout or read_password.
I also tried using read_password_from_tty which not only throws that same error after hitting enter, but also the message is not shown and the characters I type are displayed on the console.

I am currently using read_password_from_tty and it works for Linux, Mac, Windows Powershell, Windows CMD, but it fails with Windows Git Bash.

Is there any workaround for this?

@conradkleinespel
Copy link
Owner

@bochaco Hi ! I am not aware of this bug. Unfortunately I don't use Windows so I wouldn't be able to help. Windows, with it's many shells (Powershell, CMD, etc), needs a bit more testing, as far as I'm aware.

@mahkoh
Copy link

mahkoh commented Apr 15, 2020

In current versions of msys2 and git-bash, applications that use the windows console api must be run with winpty. E.g winpty program args instead of program args.

cygwin supports the conpty api since cygwin version 3.1 but msys2 and git-bash currently use older versions.

@conradkleinespel
Copy link
Owner

Would you mind checking if this bug is still present after the recent fix in #51 ?

Try this version of rpassword in Cargo.toml:

rpassword = { git = "https://github.com/conradkleinespel/rpassword", rev = "189c388" }

@bochaco
Copy link
Author

bochaco commented Jun 23, 2020

prompt_password_stdout and read_password don't throw the error but the characters I type are displayed on the console.

With read_password_from_tty the characters typed are also displayed and it throws "The handle is invalid" error after hitting enter.

@conradkleinespel
Copy link
Owner

@Heliozoa This seems like surprising behavior, that @bochaco sees when using the fix from #51. Any idea?

@Heliozoa
Copy link
Contributor

Looks like this is an issue with how Git Bash works. I found this issue SBoudrias/Inquirer.js#421, and the linked issues led me to this github-for-windows FAQ answer which suggests running the program through winpty, which fixed the problems both in read_password and read_password_from_tty when I tried it. A comment on another issue makes it sound like this would be quite difficult to fix properly:

The thing to understand first is that MinTTY does not implement a Win32 Console. Instead, it uses MSYS2's pty emulation. Therefore vagrant is absolutely correct in saying that it cannot hide the password: it really cannot, unless it learns about MSYS2's pty emulation. Which would of course be asking a bit much... what other terminal emulators should vagrant support in addition to MinTTY?

I also tried the regular command line, PowerShell 5/6 and the newer Windows Terminal and they all worked as expected.

@conradkleinespel
Copy link
Owner

conradkleinespel commented Jun 27, 2020

Alright, thanks a lot for your renewed help @Heliozoa !

In that case, I'm going to close this issue, @bochaco, as it looks like this problem is unrelated to rpassword but rather related to Git Bash. Maybe this should be reported to Git Bash project maintainers directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants