Cannot use git actions in VisualStudio (git-askpass.exe: No such file or directory)
Asked Answered
P

6

15

I have been using BitBucket as my code repository with Visual Studio, but today I'm not able to push code.

I tried to fetch, it opens a window to input the BitBucket credentials (username/email and password), the window closes and VisualStudio gives an error:

Fetching from origin Error encountered while fetching: 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 could not read Password for 'https://[email protected]': terminal prompts disabled

I tried the following but the error continues:

  • Update the Visual Studio

  • Installing the BitBucket extension for Visual Studio

  • Clearing and inserting the git credentials manually

Pernell answered 19/8, 2018 at 14:37 Comment(0)
P
10

After trying different solutions for a while I found the solution in the VisualStudio forums: https://developercommunity.visualstudio.com/solutions/310409/view.html

Thanks to James Mu.

Here are the detailed steps that worked for me:

  1. Install the latest pre-release of Git Credential Manager for Windows. You can download the .exe here: https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.16.3

  2. Open the folder C:\Program Files\Git\mingw64\libexec\git-core with the windows file explorer, order files by "Date modified" descending (most recent first), and copy the top 6 files to %DevEnvDir%\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core.

    • For me the folder is C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core.

    • If it is not for you, view the value of %DevEnvDir% with "Developer Command Prompt for VS 2017" and the "set" command.

  3. Replace the files in the destination folder.

Pernell answered 19/8, 2018 at 14:37 Comment(1)
I had the same problem and updated to Version Visual Studio 2017 15.9.3 and it works now.Chide
J
5

If you are still getting this error for Visual Studio 2019 and updating GCM is not working then please use app password instead of your regular BitBucket login password.

As of Mar 1 2022, BitBucket stopped using regular password for API based authentication. See reference

https://community.atlassian.com/t5/Bitbucket-articles/Announcement-Bitbucket-Cloud-account-password-usage-for-Git-over/ba-p/1948231


To get the app password

  1. Go to the bitbucket.org website and log in
  2. From your avatar in the bottom left, and click Personal settings
  3. Click App passwords under Access management
  4. Click Create app password
  5. Give the app password sufficient rights, and a label related to the application that will use the password
  6. Don't forget to save that password
Jayjaycee answered 7/3, 2022 at 5:10 Comment(1)
Where to find app password?Nymph
I
1
  1. Close Visual Studio and open CMD as administrator
  2. Run this command: mklink /D "C:\Git" "C:\Program Files\Git"
  3. Open Environment Variables and add GIT_ASKPASS variable with value "C:\Git\mingw64\libexec\git-core\git-askpass.exe"
  4. Open Visual Studio and push/pull or sync!
Imagism answered 18/1, 2022 at 19:2 Comment(2)
Where is the location of "Environment Variables"?Tuinal
I find the Environment Variables in Windows 10 by right click in my computer folder -->properties -->Advanced System Settings. But now the question is I have no git-askpass.exe file in the "C:\Git\mingw64\libexec\git-core\" directory!!Tuinal
A
1

As suggested by @CuriousDeveloper, you need to use app-passwords starting from Mar 2022. But I was not being prompted to enter the password anywhere, when I used the Git "Sync" button in Visual Studio's "Git Changes" tab.

When I ran git pull in the "Developer PowerShell", it then prompted me to enter a password and also displayed a warning regarding the use of app-passwords (below warning).


I followed the below steps to create a app-password and used it to login:

  1. Go to the bitbucket.org website and log in
  2. From your avatar in the bottom left, and click Personal settings
  3. Click App passwords under Access management
  4. Click Create app password
  5. Give the app password sufficient rights, and a label related to the application that will use the password
  6. Don't forget to save that password

Note that you will not be able to view you app-password again once you close the settings window, so be sure to record it.


ERROR in terminal:

fatal: Invalid credentials
remote: Bitbucket Cloud recently stopped supporting account passwords for Git authentication.
remote: See our community post for more details: https://atlassian.community/t5/x/x/ba-p/1948231
remote: App passwords are recommended for most use cases and can be created in your Personal settings:
remote: https://bitbucket.org/account/settings/app-passwords/
fatal: Authentication failed for 'https://bitbucket.org/<org>/<repo>.git/'
Astringent answered 14/9, 2022 at 8:10 Comment(0)
T
0

I was using the buttons included in menus in IntelliJ which kept giving me "\intellij-git-askpass.sh" errors and also "could not read Username for 'https://github.com': No such file or directory" and then started using the commands in the terminal instead and started working, such as:

git push --all

and/or specifically,

git push <remote> <branch>

There's also a really good cheat sheet for anyone starting out using commands

Thursby answered 22/1, 2020 at 13:5 Comment(0)
M
0

I have my repository in azure devops. The night before azure devops was down completely and the next morning I could not push or pull from my repository.

The accepted answer did not work for me. I downloaded the latest version of GIT, installed it.

It did change files in both the C:\Program Files\Git\mingw64\libexec\git-core folder and C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Common7\IDE\CommonExtensions\Microsoft\TeamFoundation\Team Explorer\Git\mingw32\libexec\git-core folder.

Tried to push again and it worked.

It might be visual studio somehow losing credentials (could be related to the outage) or I just had an older version of GIT installed.

Malamut answered 4/7, 2020 at 15:29 Comment(1)
Thanks! I downloaded latest version of GIT bash and installed. During git pull in my repo, I was able to authenticate git bash once. After that my vs2019 detected auth and was able to sync to server. The reason i got this error was I had changed my org password and VS2019 was not able to authenticate nor it asked for new password.Infantile

© 2022 - 2024 — McMap. All rights reserved.