Avinash Kumar
Avinash Kumar

Reputation: 71

Git commit error: cannot spawn gpg.exe: No such file or directory

This is what I am getting as output when I am trying to commit any file. I tried installing git again and watched some tutorials on youtube to get it started again but it didn't work. Still getting the same error:

error: cannot spawn C:\Program Files (x86)\GnuPG\bin\gpg.exe: No such file or directory
error: gpg failed to sign the data
fatal: failed to write commit object

Upvotes: 7

Views: 9462

Answers (4)

JOduMonT
JOduMonT

Reputation: 221

For me, the right answer was

git config --global gpg.program "C:\Program Files (x86)\GnuPG\bin\gpg.exe" which I found here

in your .gitconfig it must be shown like this:

[gpg]
    program = C:\\Program Files (x86)\\GnuPG\\bin\\gpg.exe

Upvotes: 0

Vishal R
Vishal R

Reputation: 189

I also faced this issue and was able to fix it by removing quotes for the gpg.exe program line in .gitconfig file.

.gitconfig file before update =>

[gpg] program = 'C:\Users\TEST\AppData\Local\GnuPG\bin\gpg.exe'

.gitconfig file after update =>

[gpg] program = C:\Users\TEST\AppData\Local\GnuPG\bin\gpg.exe

Upvotes: 2

Kolappan N
Kolappan N

Reputation: 4011

If you are using Git bash in Windows to generate the key instead of GnuPG Win, then you need to update the git config to point to the right location of gnupg. Run the following command in git bash with the correct location.

git config --global gpg.program /usr/bin/gpg

If you don't know the location run which gpg in git bash to obtain the location.

Upvotes: 9

Marcin Kłopotek
Marcin Kłopotek

Reputation: 5961

Judging from the error message:

error: cannot spawn C:\Program Files (x86)\GnuPG\bin\gpg.exe: No such file or directory
error: gpg failed to sign the data fatal: failed to write commit object

you have git gpg signing turned on but no GnuPG installed. Either install it or turn off commit gpg signing. You can disable commit signing using --no-gpg-sign flag on a particular commit command:

git commit --no-gpg-sign

or disable it permanently by modyfing your global .gitconfig:

git config --global commit.gpgsign false

Upvotes: 5

Related Questions