Git-Credential-Manager-for-Windows icon indicating copy to clipboard operation
Git-Credential-Manager-for-Windows copied to clipboard

How to update version for VSCode

Open reidca opened this issue 6 years ago • 9 comments

I am having some issues with VSCode constantly prompting for credentials for BitBucket. This is driving me mad!

To try to fix this I have updated both "Git for Windows" and "Git Credential Manager for Windows" however for whatever reason the update does not seem to have applied.

If I run >>git credential-manager version It always returns:

Git Credential Manager for Windows version 1.16.2

If I look in the installed program list however it shows "Microsoft Git Credential Manager for Windows 1.17.1"

So my question is how do I make Git for Windows use the latest installed version of Git Credential Manager?

Thanks

reidca avatar Aug 21 '18 17:08 reidca

VS Code, I believe, uses the Git found on %PATH%, so it should be using the updated one.

However, I'm not sure - I recommend opening an issue on the Code issue tracker (also on GitHub)

whoisj avatar Aug 21 '18 21:08 whoisj

Tried opening an issue on the VSCode issue tracker but am getting nowhere. They say that VSCode just calls git.exe. How does Git know which version of the credential manager to use? Despite having the latest version of the credential manager installed GIT still uses the old version - that must be a setting somewhere in Git but I cannot find it.

reidca avatar Aug 28 '18 08:08 reidca

@reidca VSCode invokes the first Git it finds on your %PATH%. Git uses git config --list looking for credential.helper=... and calls the first one registered.

Your best bet is to run the git config --list --show-origin command and validate the credential.helper = values listed. Running from the root of the repository will include any local repository configuration values as well.

whoisj avatar Aug 28 '18 14:08 whoisj

OK so this shows me:

C:/Users/[username]/.gitconfig credential.helper=manager

"manager" must resolve to something - how does Git-Credential-Manager-for-Windows register itself as "manager". I assume when the new version is installed some kind of mapping must occur between that and the actual version. If I can work this out then I assume I can re point it to use the later version.

reidca avatar Sep 05 '18 14:09 reidca

"manager" must resolve to something

So when Git sees a naked work like "manager" it assumes you're looking for "git-manager", except in this case because it is "git-credential" running it assumes "git-credential-manager". It then does a look up based on its internal logic for precedence and comes up with "$GIT_INSTALL\mingw64\libexec\git-core\git-credential-manager.exe".

Git will then pass that path to CreateProcessW.

whoisj avatar Sep 05 '18 19:09 whoisj

Thank you for explaining that. This explains why when I run "git credential-manager version" it returns "Git Credential Manager for Windows version 1.16.2"

It seems that when I install the latest version of "Microsoft Git Credential Manger for Windows" which is 1.17.1 it installs into "C:\Users[username]\AppData\Local\Programs\Microsoft Git Credential Manager for Windows". This is clearly not going to be resolved by GIT as things are.

So the next logical question is how to tell GIT to use that version instead of the version at "$GIT_INSTALL\mingw64\libexec\git-core\git-credential-manager.exe".

I would have thought that this would have happened during the installation however the installation was totally silent and there was no dialogs or any other ways of specifying the path or configuration.

Sorry if this appears obvious to you but it certainly is not to me and I could not work this out from the information I have read.

reidca avatar Sep 06 '18 07:09 reidca

You can just copy the files from %LocalAppData%\Programs\Microsoft Git Credential Manager for Windows to $GIT_INSTALL\mingw64\libexec\git-core\, overwriting any files in the destination. That should get you unblocked.

Now for my real question: why is anything installing GCM to %LocalAppData%?!

whoisj avatar Sep 06 '18 13:09 whoisj

Is there not a way to tell Git to use the version installed somewhere else? How is this working for anyone else? I have not made any unusual changes. I just installed Git for Windows, then VS code, then Git Credential Manager. Not sure what else I could have done to make the new version used by Git?

Now for my real question: why is anything installing GCM to %LocalAppData%?! This is the location that is used by the installer (https://github.com/Microsoft/Git-Credential-Manager-for-Windows/releases/tag/v1.17.1) I didn't change anything when installing it.

reidca avatar Sep 06 '18 13:09 reidca

Yes you can replace credential.helper = manager with credential.helper = /c/Users/[username]/AppData/Local/Programs/Microsoft\ Git\ Credential\ Manager/git-credential-manager.exe but YMMV.

whoisj avatar Sep 07 '18 13:09 whoisj