VisualStudio icon indicating copy to clipboard operation
VisualStudio copied to clipboard

Can't login to GitHub

Open HisRoyalRedness opened this issue 9 years ago • 154 comments

NOTE: Updating to Visual Studio 2017 15.5.7 or later should fix this. See https://github.com/github/VisualStudio/issues/949#issuecomment-367821388

I'm having some trouble logging on to GutHib to push new changes to my repository. I've just recently upgraded to Visual Studio 17. Everything used to work on VS 2015, but doesn't any longer.

  • GitHub Extension for Visual Studio version: 2.2.0.8
  • Visual Studio 2017 Professional: Ver 15.0.0+26228.9
  • Windows 7 Pro SP1

Detailed steps:

  • I have a local clone of a public (personal) repository. I've made changes to the local files
  • Staged the changes.
  • Attempted to push the changes.
  • The GitHub login dialog appears. I've entered my username and password. I've confirmed that these are correct by logging in to the website.
  • I get the following in my ouput pane on Visual Studio
Opening repositories:
### Local path, removed the actual path to anonymise ###
Error encountered while pushing to the remote repository: Git failed with a fatal error.
fatal: AggregateException encountered.
   One or more errors occurred.
error: cannot spawn askpass: No such file or directory
fatal: could not read Username for 'https://github.com': terminal prompts disabled
Pushing to https://github.com/### repo path ###.git

I have 2 factor enabled on my account.

HisRoyalRedness avatar Apr 04 '17 01:04 HisRoyalRedness

This is definitely related to the VS 15.7.6 update. I was able to push and pull yesterday, then updated VS, now no go. Identical behavior at work. The file itself (git-askpass.exe) does exist.

Monte-Christo avatar Aug 07 '18 18:08 Monte-Christo

Thanks for that trace log @GarrettDavis. The root error message there is The underlying connection was closed: The connection was closed unexpectedly. This message is being reported by Git Credential Manager for Windows.

All, we saw error message like this when GitHub deprecated support for TLS1.0 and TLS1.1. I have no idea, though I will try to find out, if Atlassian has done something similar. In the meantime you can reference this Developer Community topic to potentially find workarounds for your current situation.

Update: It looks like Atlassian made some changes to BitBucket's networking on 06-Aug-18 (yesterday). I'm not blaming these changes, but it is something to consider when trying to debug what is happening here.

Update 2: I've found the cause of the cannot spawn /C/Program Files (x86)/.../git-askpass.exe: No such file or directory error message, and while I've prepared a fix for it (future version of VS), the message is a red herring as the only way to reach this error state is to run into the The underlying connection was closed: The connection was closed unexpectedly first and git-askpass.exe would fail to do anything to resolve the issue (it just reports already cached credentials).

TL;DR The cannot spawn /C/Program Files (x86)/.../git-askpass.exe: No such file or directory message is a symptom of credential acquisition failing unexpectedly. Understanding the credential acquisition failure, not the failure to find git-askpass, will resolve the issue.

whoisj avatar Aug 07 '18 18:08 whoisj

but for now, going ssh is the only option besides using command line git commands? Reinstalling Visual studio is pretty cumbersome...

ivleth avatar Aug 08 '18 07:08 ivleth

From @davidscherf in #1841

  • GitHub Extension for Visual Studio version: 2.5.4.3349
  • Visual Studio version: 15.7.6

Pull or push no longer works

Git failed with a fatal error. HttpRequestException encountered. An error occurred while sending the request. cannot spawn /C/Program Files (x86)/Microsoft Visual > Studio/2017/Community/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/Git/mingw32/libexec/git-core/git-askpass.exe: No such file or directory

@davidscherf could you let us know where your repository is located?

grokys avatar Aug 08 '18 07:08 grokys

The cannot spawn /C/Program Files (x86)/.../git-askpass.exe: No such file or directory message is a symptom of credential acquisition failing unexpectedly.

@whoisj I know this is probably easier said than done, but would it be possible to display a more helpful error message when such things fail? cannot spawn /C/Program Files (x86)/.../git-askpass.exe isn't just unhelpful, it's misleading...

grokys avatar Aug 08 '18 07:08 grokys

@whoisj yes. The file git-askpass.exe does exist in "\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core".

and here is the log:

09:34:02.374429 git.c:340               trace: built-in: git 'remote' '--verbose'
09:34:02.405671 git.c:340               trace: built-in: git 'remote' '--verbose'
09:34:02.436914 git.c:340               trace: built-in: git 'remote' '--verbose'
09:34:02.468157 git.c:340               trace: built-in: git 'remote' '--verbose'
09:34:02.499399 git.c:340               trace: built-in: git 'remote' '--verbose'
09:34:02.530642 git.c:340               trace: built-in: git 'remote' '--verbose'
09:34:02.546263 git.c:340               trace: built-in: git 'remote' '--verbose'
09:34:02.577506 git.c:340               trace: built-in: git 'remote' '--verbose'
09:34:07.002017 git.c:340               trace: built-in: git 'for-each-ref' '--format='\''[%(refname)][%(objecttype)][%(objectname)][%(upstream)][%(push)][%(HEAD)]'\''' 'refs/heads/' 'refs/remotes/'
09:34:07.033932 git.c:340               trace: built-in: git 'cat-file' '--batch=[%(objectname)][%(objecttype)][%(objectsize)]'
09:34:07.126684 git.c:340               trace: built-in: git 'config' '--show-origin' '--list' '-z'
09:34:07.765977 git.c:340               trace: built-in: git 'rev-parse' '--git-dir' '--git-common-dir' '--is-bare-repository' '--git-path' 'index' '--git-path' 'objects/' '--git-path' 'hooks/' '--git-path' 'info/' '--git-path' 'logs/' '--git-path' 'HEAD' '--git-path' 'description' '--git-path' 'refs/' '--show-toplevel' '--shared-index-path'
09:34:07.800883 git.c:340               trace: built-in: git 'status' '--porcelain=v2' '--branch' '--no-lock-index' '--untracked-files=all' '--show-ignored-directory' '--ignore-submodules=none' '--ignored'
09:34:07.844765 git.c:340               trace: built-in: git 'rev-list' '--use-bitmap-index' '--header' 'refs/heads/master..refs/remotes/origin/master' '--'
09:34:07.870696 git.c:340               trace: built-in: git 'rev-list' '--use-bitmap-index' '--header' 'refs/remotes/origin/master..refs/heads/master' '--'
09:34:10.077660 git.c:340               trace: built-in: git 'config' '--show-origin' '--list' '-z'
09:34:13.339267 git.c:340               trace: built-in: git 'remote' '--verbose'
09:34:13.358216 git.c:340               trace: built-in: git 'for-each-ref' '--format='\''[%(refname)][%(objecttype)][%(objectname)][%(upstream)][%(push)][%(HEAD)]'\''' 'refs/heads/' 'refs/remotes/'
09:34:13.380157 git.c:340               trace: built-in: git 'rev-list' '--use-bitmap-index' '--header' 'master..origin/master' '--'
09:34:13.399107 git.c:340               trace: built-in: git 'rev-list' '--use-bitmap-index' '--header' 'origin/master..master' '--'
09:34:13.420050 git.c:340               trace: built-in: git 'merge-base' '97994592098b587b51f48f669a85c034bc743918' '97994592098b587b51f48f669a85c034bc743918'
09:34:13.441992 git.c:340               trace: built-in: git 'cat-file' '--batch=[%(objectname)][%(objecttype)][%(objectsize)]'
09:34:17.559785 git.c:340               trace: built-in: git 'config' '--show-origin' '--list' '-z'
09:34:21.561859 git.c:340               trace: built-in: git 'update-index' '--add' '--remove' '--verbose' '--stdin'
09:34:21.608723 git.c:340               trace: built-in: git 'commit' '--allow-empty-message' '--file=-'
09:34:21.655587 git.c:340               trace: built-in: git 'for-each-ref' '--format='\''[%(refname)][%(objecttype)][%(objectname)][%(upstream)][%(push)][%(HEAD)]'\''' 'refs/heads/' 'refs/remotes/'
09:34:21.671208 git.c:340               trace: built-in: git 'cat-file' '--batch=[%(objectname)][%(objecttype)][%(objectsize)]'
09:34:21.686829 git.c:340               trace: built-in: git 'status' '--porcelain=v2' '--branch' '--no-lock-index' '--untracked-files=all' '--show-ignored-directory' '--ignore-submodules=none' '--ignored'
09:34:21.782063 git.c:340               trace: built-in: git 'remote' '--verbose'
09:34:21.784058 git.c:340               trace: built-in: git 'rev-list' '--use-bitmap-index' '--header' 'refs/heads/master..refs/remotes/origin/master' '--'
09:34:21.802010 git.c:340               trace: built-in: git 'for-each-ref' '--format='\''[%(refname)][%(objecttype)][%(objectname)][%(upstream)][%(push)][%(HEAD)]'\''' 'refs/heads/' 'refs/remotes/'
09:34:21.803007 git.c:340               trace: built-in: git 'rev-list' '--use-bitmap-index' '--header' 'refs/remotes/origin/master..refs/heads/master' '--'
09:34:21.821956 git.c:340               trace: built-in: git 'rev-list' '--use-bitmap-index' '--header' 'master..origin/master' '--'
09:34:21.840906 git.c:340               trace: built-in: git 'rev-list' '--use-bitmap-index' '--header' 'origin/master..master' '--'
09:34:21.860852 git.c:340               trace: built-in: git 'merge-base' '1a5bdd6a3d589ee43ab78a497606c47d584fba3a' '97994592098b587b51f48f669a85c034bc743918'
09:34:21.880799 git.c:340               trace: built-in: git 'cat-file' '--batch=[%(objectname)][%(objecttype)][%(objectsize)]'
09:34:21.924868 git.c:340               trace: built-in: git 'for-each-ref' '--format='\''[%(refname)][%(objecttype)][%(objectname)][%(upstream)][%(push)][%(HEAD)]'\''' 'refs/heads/' 'refs/remotes/'
09:34:21.956111 git.c:340               trace: built-in: git 'remote' '--verbose'
09:34:21.971733 git.c:340               trace: built-in: git 'push' '--verbose' '--progress' 'origin' 'refs/heads/master:master'
09:34:21.971733 run-command.c:626       trace: run_command: 'remote-https' 'origin' 'https://[email protected]/uzername/reponame.git'
09:34:21.987354 git.c:572               trace: exec: 'git-remote-https' 'origin' 'https://[email protected]/uzername/reponame.git'
09:34:21.987354 run-command.c:626       trace: run_command: 'git-remote-https' 'origin' 'https://[email protected]/uzername/reponame.git'
09:34:22.702266 git.c:340               trace: built-in: git 'for-each-ref' '--format='\''[%(refname)][%(objecttype)][%(objectname)][%(upstream)][%(push)][%(HEAD)]'\''' 'refs/heads/' 'refs/remotes/'
09:34:22.717887 git.c:340               trace: built-in: git 'cat-file' '--batch=[%(objectname)][%(objecttype)][%(objectsize)]'
09:34:22.967828 run-command.c:626       trace: run_command: 'git credential-manager get'
09:34:22.999072 git.c:572               trace: exec: 'git-credential-manager' 'get'
09:34:22.999072 run-command.c:626       trace: run_command: 'git-credential-manager' 'get'
09:34:23.045936 ...\Common.cs:665       trace: [Main] git-credential-manager (v1.16.2) 'get'
09:34:23.077178 ...\Git\Where.cs:343    trace: [FindGitInstallations] found 1 Git installation(s).
09:34:23.092800 ...Configuration.cs:222 trace: [LoadGitConfiguration] git All config read, 34 entries.
09:34:23.092800 ...\Common.cs:393       trace: [LoadOperationArguments] GCM_HTTP_USER_AGENT = 'git-credential-manager (Microsoft Windows NT 10.0.17134.0; Win32NT x64) CLR/4.0.30319 VS15/15.0.0'.
09:34:23.092800 ...\Common.cs:445       trace: [LoadOperationArguments] interactive = 'Auto'.
09:34:23.092800 ...\Common.cs:463       trace: [LoadOperationArguments] validate = 'True'.
09:34:23.092800 ...\Common.cs:479       trace: [LoadOperationArguments] modalPrompt = 'True'.
09:34:23.108421 ...\Common.cs:84        trace: [CreateAuthentication] detecting authority type for 'https://[email protected]/'.
09:34:23.124102 ...uthentication.cs:319 trace: [GetAuthentication] authentication for Bitbucket created
09:34:23.124102 ...\Common.cs:173       trace: [CreateAuthentication] authority for 'https://[email protected]/'  is Bitbucket
09:34:23.162998 ...icationPrompts.cs:96 trace: [CredentialModalPrompt] prompting user for credentials.
09:34:31.608967 ...\RestClient.cs:33    trace: [TryGetUser] server responded with Unauthorized.
09:34:31.608967 ...\RestClient.cs:59    trace: [TryGetUser] authentication unauthorized
09:34:31.609965 ...hAuthenticator.cs:38 trace: [GetAuthAsync] authentication failed
09:34:31.609965 ...uthentication.cs:393 trace: [InteractiveLogon] interactive logon failed
09:34:31.613954 ...\Authority.cs:214    trace: [ValidateCredentials] authentication type = 'Credential'.
09:34:32.597327 ...\RestClient.cs:33    trace: [TryGetUser] server responded with Unauthorized.
09:34:32.597327 ...\RestClient.cs:59    trace: [TryGetUser] authentication unauthorized
09:34:32.597327 ...\Authority.cs:225    trace: [ValidateCredentials] credential validation failed
09:34:32.598324 ...\Authority.cs:214    trace: [ValidateCredentials] authentication type = 'Token'.
09:34:32.598324 ...\Network.cs:457      trace: [GetHttpClient] ! unsupported token type, not appending an authentication header to the request.
09:34:35.593321 ...\Git\Trace.cs:139    trace: [WriteException] ! error: 'An error occurred while sending the request.'.
09:34:35.593321 ...\Git\Trace.cs:143    trace: [WriteException]        > 'The underlying connection was closed: The connection was closed unexpectedly.'.
09:34:35.596313 ...\Common.cs:630       trace: [LogEvent] System.Net.Http.HttpRequestException: An error occurred while sending the request. ---> System.Net.WebException: The underlying connection was closed: The connection was closed unexpectedly.
   at System.Net.HttpWebRequest.EndGetResponse(IAsyncResult asyncResult)
   at System.Net.Http.HttpClientHandler.GetResponseCallback(IAsyncResult ar)
   --- End of inner exception stack trace ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Alm.Authentication.Network.<HttpGetAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Atlassian.Bitbucket.Authentication.Rest.RestClient.<TryGetUser>d__4.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Atlassian.Bitbucket.Authentication.Authority.<ValidateCredentials>d__9.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Atlassian.Bitbucket.Authentication.Authority.<ValidateCredentials>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Atlassian.Bitbucket.Authentication.Authentication.<ValidateCredentials>d__33.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Alm.Cli.CommonFunctions.<QueryCredentials>d__10.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Alm.Cli.Program.<>c__DisplayClass23_1.<<Get>b__0>d.MoveNext()
09:34:35.597310 ...\Program.cs:578      trace: [Run] fatal: HttpRequestException encountered.
   An error occurred while sending the request.
09:34:35.953724 run-command.c:626       trace: run_command: '/C/Program Files (x86)/Microsoft Visual Studio/2017/Version/Common7/IDE/CommonExtensions/Microsoft/TeamFoundation/Team Explorer/Git/mingw32/libexec/git-core/git-askpass.exe' 'Password for '\''https://[email protected]'\'': '

I'm using BitBucket.

JedatKinports avatar Aug 08 '18 07:08 JedatKinports

I just updated to 15.8.0 Preview 5.0 and it broke git causing this error message.

HttpRequestException encountered. An error occurred while sending the request. cannot spawn /c/program files (x86)/microsoft visual studio/preview/enterprise/common7/ide/commonextensions/microsoft/teamfoundation/team explorer/Git/mingw32/libexec/git-core/git-askpass.exe: No such file or directory could not read Username for 'https://bitbucket.org': terminal prompts disabled

15.7.2 which I also have installed has no problem doing a push from the same .sln file.

It seems the new installer may have removed git by default?

rollsch avatar Aug 08 '18 07:08 rollsch

I am using SourceTree or git bash to do my pushing and pulling while VS 2017 refuses to sync. Tortoise Git or any other Git client would work as well, I guess. In my case, only syncing to BitBucket is broken. GitHub repos sync just fine.

Monte-Christo avatar Aug 08 '18 08:08 Monte-Christo

Have a look here.

AmosHason avatar Aug 08 '18 08:08 AmosHason

In visual studio > Team Explorer > Repository settings > Remotes

Replace

login@.,... with login:pass@... etc

Like

https://login:[email protected]/myrepo/myproject.git_

OR (better)

Just overwrite as described below: https://github.com/github/VisualStudio/issues/949#issuecomment-411349635

ivleth avatar Aug 08 '18 08:08 ivleth

So i ran into this error and it seems that the bundled Git-Credential-Manager-for-Windows/ in VIsual Studio 2017 is not of the latest release yet. Downloading the latest release and putting it on top of the files in VIsual Studio 2017 worked for me.

1. download the zip file gcmw-v1.17.0.zip from https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases
2. navigate to C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\ (or wherever your 'missing' git-askpass.exe resides).
3. make a copy of the git-core folder and rename it backup or something like that
4. put the files from the zip file on top of the contents of your new git-core folder and overwrite where prompted

Let me know if this works for you


Edit

might wanna use gcmw-v1.17.1.zip if the 1.17.0 did not work

kevinramharak avatar Aug 08 '18 09:08 kevinramharak

and yes that is working! Brilliant!

ivleth avatar Aug 08 '18 11:08 ivleth

@KevinRamharak it's working, thanks!

lucas-moura avatar Aug 08 '18 11:08 lucas-moura

For me workaround by @KevinRamharak with overwriting Git-Credential-Manager-for-Windows with latest version didn't worked until I've removed "login" from remote settings (i.e changed https://[email protected]/myrepo/myproject.git to https://bitbucket.org/myrepo/myproject.git) and also started to use Atlassian ID with full email instead.

vlardn avatar Aug 08 '18 13:08 vlardn

@whoisj I did confirm it few posts earlier. File is there, seating there in proper warm corner and making nest

TymekMM avatar Aug 08 '18 14:08 TymekMM

@KevinRamharak Works like a charm. Thanks. I had installed latest Git-Credential-Manager-for-Windows earlier, but only manually overwriting the files fixed the issue for me.

Monte-Christo avatar Aug 08 '18 15:08 Monte-Christo

@KevinRamharak - awesome - fix worked! thanks!

DoumaWebDesign avatar Aug 09 '18 03:08 DoumaWebDesign

For me, I did overwrite Git-Credential-Manager-for-Windows with the latest version just as what @KevinRamharak said. But then I need to go to Control Panel > Credential Manager, and directly input my username (using full email for the Atlassian ID) and password in the required credential for the login to work.

samuelalvin avatar Aug 09 '18 06:08 samuelalvin

@KevinRamharak - You are a life saver!!!! fix worked thanks!

rafalowski avatar Aug 09 '18 08:08 rafalowski

@KevinRamharak - Big thanks for your help! It's working! Edited: Only work on my Win7. In Win10 didn't work :(

willandus avatar Aug 09 '18 08:08 willandus