Closed bochaco closed 4 years ago
@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.
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.
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" }
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.
@Heliozoa This seems like surprising behavior, that @bochaco sees when using the fix from #51. Any idea?
Looks like this is an issue with how Git Bash works. I found this issue https://github.com/SBoudrias/Inquirer.js/issues/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.
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.
I'm getting OS error 6 ("The handle is invalid") on Windows using Git Bash when calling
prompt_password_stdout
orread_password
. I also tried usingread_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?