GPG4Win v5 - Can't sign a GIT commit in Visual Studio

Hi,

I have been successfully signing my GIT commits in Visual Studio for several years using x86 versions of GPG/GPG4Win. I just updated to the new v5 release and find that, after I reboot my PC, signing fails because the signing agent isn’t running.

If I start the agent manually, signing in VS works fine again until I reboot. Is there some configuration that needs to be changed on upgrading from the x86 to the x64 GPG4Win version to ensure the agent is automatically started or is started by VS when needed?

Many thanks, Peter

Hi Peter,

I guess you have to update your Visual Studio configuration because it is configured like described here for v4: Commit Signing · microsoft/vscode Wiki · GitHub , correct?

The code path for gpg now has to be updated to the new location, the default for Gpg4win v5 is C:\Program Files\GnuPG\bin\gpg.exe

Hi,

Thanks for your reply. I do have Git configured correctly because commits are fine after I get the daemon running. The issue is that the daemon, which is supposed to self-start, either doesn’t or is picking up incorrect information and failing in some way.

I’ve spent way too much time on this! :grin: There is one version of GPG in the Git\Usr\bin folder and another in the GnuPG\bin folder. There are some GPG settings in my %userproifile%.gnupg folder and more files in the AppData\local folder and even more in the AppData\roaming folder

Some versions appear to use the profile files while others use the roaming files. I kept trying to work this out and was getting more and more confused so I restored my C: driver to the state before I installed GPG4Win v5, installed V5 again, and configured Git per your link.

After this signing worked fine again (and faster than before I installed V5),. However, after a reboot signing failed per my original post.

I’ve now created a scheduled task that runs at logon to manually start the daemon:

Task Program: “C:\Program Files\GnuPG\bin\gpg-connect-agent.exe”

Task Parameters: –quiet /bye

I do see an ugly command prompt when the program runs but it’s gone in a few seconds and the daemon is left running, so my first commit now succeeds. :+1:

Sorry for the long post, but I suspect that I won’t be the only person who has this issue and I wanted to record the solution that worked for me.

Best wishes, Peter

Sorry for jumping to conclusions and thank you for describing your workaround!

Then the issue that the gpg-agent does not start by itself might be related to this bug:

Regarding the multiple locations with gpg related binaries and settings:
From Gpg4win are the binaries below C:\Program Files\GnuPG and C:\Program Files\Gpg4win.
Configuration files are mainly in a users AppData\roaming\gnupg folder, all configuration is below AppData.

The configuration in %USERPROFILE% is likely from your git installation, which obviously installs its own gpg, as the binaries below Git show.

I’d recommend putting Gpg4win and GnuPG earlier in the PATH as git, so that you will use the more up to date gpg version.