threads / discuss / 41562

Git 2.7.2.windows.1 fails to authenticate access to private repository over HTTPS

Subject: Git 2.7.2.windows.1 fails to authenticate access to private repository over HTTPS

## tl;dr

2 messages between Feb 29, 2016 and Feb 29, 2016.

replies: 1people: 2as markdown or json

zacr· Feb 29, 2016, 03:24 UTC · lore
Hi,

I have recently downloaded 64-bit Git for Windows (the file I downloaded was "Git-2.7.2-64-bit.exe"). This reports a version string of "git version 2.7.2.windows.1" Using it from the command line, after cloning a repository, I attempted to "git pull" a private repository from GitHub. From prior experience, I expected it to ask me for my username and password, then authenticate with the server. It asked for my username, which I typed in, but after pressing Enter it suddenly failed with an error:

error: failed to execute prompt script (exit code 1) fatal: could not read Username for 'https://github.com': Invalid argument

I experimented a bit, and it only occurs when trying to use HTTPS to pull from a repository that requires authentication. Using a personal access token to authenticate or using the git protocol both work.

I ran it again with GIT_TRACE=true, and here is the trace (with username and repository name removed):

15:55:58.615147 git.c:348 trace: built-in: git 'pull' 15:55:58.617147 run-command.c:343 trace: run_command: 'fetch' '--update-head-ok' 15:55:58.633149 git.c:348 trace: built-in: git 'fetch' '--update-head-ok' 15:55:58.636149 run-command.c:343 trace: run_command: 'git-remote-https' 'origin' 'https://github.com/username/repository.git' 15:55:59.630248 run-command.c:343 trace: run_command: 'bash' '-c' 'cat >/dev/tty && read -r line </dev/tty && echo "$line"' error: failed to execute prompt script (exit code 1) fatal: could not read Username for 'https://github.com': Invalid argument

It looks like it's trying to run a new bash instance for me to enter my password, which fails on Windows because I don't have bash installed.

For reference, here are some old threads I found while researching the issue. It looks like this has cropped up before, in Git 1.8.5. https://groups.google.com/forum/#!msg/msysgit/s4dB8Nv9V4c/55-cGPdPYmAJ https://github.com/msysgit/msysgit/issues/153 and stackoverflow for good measure (comments by Mr_and_Mrs_D, Ricardo, and AndyL identify it as a bug with 1.8.5): http://stackoverflow.com/questions/20871549/error-when-push-commits-with-github-fatal-could-not-read-username

I would appreciate your help.

Yours sincerely, Zac Roberts zacr@slingshot.co.nz

Johannes Schindelin· Feb 29, 2016, 13:30 UTC · re: zacr · lore

Re: Git 2.7.2.windows.1 fails to authenticate access to private repository over HTTPS

Hi Zac,
On Mon, 29 Feb 2016, zacr wrote:
Show 6 quoted lines
> I have recently downloaded 64-bit Git for Windows (the file I downloaded
> was "Git-2.7.2-64-bit.exe"). This reports a version string of "git
> version 2.7.2.windows.1"
>
> Using it from the command line, after cloning a repository, I attempted
> to "git pull" a private repository from GitHub.
Are you using Git CMD? It is rather crucial to get such details right.
Show 15 quoted lines
> 15:55:58.615147 git.c:348               trace: built-in: git 'pull'
> 15:55:58.617147 run-command.c:343       trace: run_command: 'fetch'
> '--update-head-ok'
> 15:55:58.633149 git.c:348               trace: built-in: git 'fetch'
> '--update-head-ok'
> 15:55:58.636149 run-command.c:343       trace: run_command:
> 'git-remote-https' 'origin' 'https://github.com/username/repository.git'
> 15:55:59.630248 run-command.c:343       trace: run_command: 'bash' '-c' 'cat
> >/dev/tty && read -r line </dev/tty && echo "$line"'
> error: failed to execute prompt script (exit code 1)
> fatal: could not read Username for 'https://github.com': Invalid argument
> 
> 
> It looks like it's trying to run a new bash instance for me to enter my
> password, which fails on Windows because I don't have bash installed.

You do have bash installed. Unless you went out of your way to delete it after installing Git for Windows.

Assuming that you used Git CMD to perform your test, the sad news is that I cannot reproduce your problem here.

Let's first of all try to make a Minimal, Complete & Verifiable Example (MCVE). In other words, let's find the minimal set of steps with no prerequisites (such as local clones of private repositories) that *still* reproduce the bug. This is in general a Very Good Idea if you are reporting bugs because it not only shows that you are dedicated to see this bug fixed but also that you are not expecting only others to invest a ton of time into the bug fix.

In your case, the problem is easily triggered without a local clone at all. A simple `git ls-remote https://github.com/user/repository.git` is enough, and would count as *Minimal* as per that MCVE acronym.

Alas, when I issue this (with GIT_TRACE=1), I get this:

-- snip -- C:\Users\me>set GIT_TRACE=1

C:\Users\me>git ls-remote https://github.com/user/repository.git 14:14:01.717354 git.c:348 trace: built-in: git 'ls-remote' 'https://github.com/user/repository.git' 14:14:01.718331 run-command.c:343 trace: run_command: 'git-remote-https' 'https://github.com/user/repository.git' 'https://github.com/user/repository.git' 14:14:02.599651 run-command.c:343 trace: run_command: 'bash' '-c' 'cat >/dev/tty && read -r line </dev/tty && echo "$line"' Username for 'https://github.com': 123 14:14:06.822993 run-command.c:343 trace: run_command: 'bash' '-c' 'cat >/dev/tty && read -r -s line </dev/tty && echo "$line" && echo

>/dev/tty'

Password for 'https://123@github.com': remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/user/repository.git/' -- snap --

So at first I thought maybe you called
	C:\Program Files\Git\mingw64\bin\git.exe

directly, which is a user mistake that is unfortunately quite frequent, the appropriate entry point is instead

	C:\Program Files\Git\cmd\git.exe

But even then, it succeeds for me (without having sh.exe nor bash.exe in the PATH):

-- snip -- C:\Users\me>"\Program Files"\git\mingw64\bin\git ls-remote https://github.com/user/repository.git 14:22:44.320489 git.c:348 trace: built-in: git 'ls-remote' 'https://github.com/user/repository.git' 14:22:44.321470 run-command.c:343 trace: run_command: 'git-remote-https' 'https://github.com/user/repository.git' 'https://github.com/user/repository.git' 14:22:44.990258 run-command.c:343 trace: run_command: 'bash' '-c' 'cat >/dev/tty && read -r line </dev/tty && echo "$line"' Username for 'https://github.com': 123 14:22:45.840206 run-command.c:343 trace: run_command: 'bash' '-c' 'cat >/dev/tty && read -r -s line </dev/tty && echo "$line" && echo >/dev/tty' Password for 'https://123@github.com': remote: Invalid username or password. fatal: Authentication failed for 'https://github.com/user/repository.git/' -- snap --

Maybe your setup has something funky going on that my setup lacks.

Lastly, for the record, the best way to report bugs in Git for Windows is through the bug tracker at https://github.com/git-for-windows/git/issues. I tried to make this obvious on Git for Windows' home page at https://git-for-windows.github.io/#contribute.

Maybe you have an idea how I could make it more obvious to users who prefer visiting StackOverflow over visiting Git for Windows' home page?

Ciao, Johannes

← back to recent threads