Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can’t commit and push in Git because “cannot spawn gpg2: No such file or directory”

Anytime I've tried to commit a change through the command line I've received this error message:

error: cannot spawn gpg2: No such file or directory

Update: I'm running Windows 10

like image 844
Anthony Mack Avatar asked Feb 08 '20 20:02

Anthony Mack


2 Answers

(using Github Desktop in Windows 10)

after making new gpg like in below link, (I wanted to sign my commits)

https://gist.github.com/BoGnY/f9b1be6393234537c3e247f33e74094a

in command, I could use git commit without any errors.

but in the desktop application, I got the same error, and setting gpg path worked for me. (with verified commit with app)

where gpg

it will give something like "C:\Program Files\Git\usr\bin\gpg.exe"

and using git bash, try this command

git config --global gpg.program "/c/Program Files/Git/usr/bin/gpg.exe"
like image 69
alfex4936 Avatar answered Sep 21 '22 22:09

alfex4936


By default, the program used to sign commits is gpg. On your system, it's been configured to gpg2.

Normally, signed commits are only generated when you either specify them with -S or when you have commit.gpgsign set to true, in which case all commits are signed. If you want to continue to sign commits, you can change the binary used to sign them by running git config --global gpg.program gpg, assuming that gpg exists on your system. (You can check by running command -v gpg and seeing if it provides any output.)

If gpg doesn't exist on your system, you can install it from your system package manager. Often the name of the package is gnupg, but it may differ. You haven't said what operating system you're using, so we can't provide you more specific information.

If you don't want to sign commits, then you can run git config --unset-all commit.gpgsign and signing will default to being disabled.

like image 25
bk2204 Avatar answered Sep 20 '22 22:09

bk2204