Git Hub Desktop on Mac, error: cannot run gpg: No such file or directory

Solution 1:

Solved it.

So as GitHub Desktop was complaining about not being able to find gpg (I had installed it via homebrew), I figured there should be a way to tell git the exact path of gpg, turns out there is:

gpg.program Use this custom program instead of "gpg" found on $PATH when making or verifying a PGP signature. The program must support the same command-line interface as GPG, namely, to verify a detached signature, "gpg --verify $file - <$signature" is run, and the program is expected to signal a good signature by exiting with code 0, and to generate an ASCII-armored detached signature, the standard input of "gpg -bsau $key" is fed with the contents to be signed, and the program is expected to send the result to its standard output. https://git-scm.com/docs/git-config

So running the following solved the problem:

git config --global gpg.program "$(which gpg)"

GitHub got back to me and said that some users also need to use:

echo "no-tty" >> ~/.gnupg/gpg.conf

Solution 2:

It has something to do with commit signing (https://help.github.com/en/articles/signing-commits).

In case you use Github Desktop (which doesn't support commit signing as highlighted right at the beginning of the article linked above) or if you don't need commit signing (or don't even know what it is), one thing you can do is to disable gpg commit signing by running a command like git config --global commit.gpgsign false or edit your .git/config file manually:

[commit]
  # https://help.github.com/articles/signing-commits-using-gpg/
  gpgsign = false

Hope it helps someone.

Solution 3:

For Mac and gpg2 installed

git config --global gpg.program $(which gpg2)

This works for me.

And after above command, your .gitconfig should look like below

[user]
    email = [email protected]
    name = jadhavy
    signingkey = xxx
[credential]
    helper = osxkeychain
[gpg]
    program = /usr/local/MacGPG2/bin/gpg2
[commit]
    gpgsign = true
[core]
    autocrlf = input

Solution 4:

SOLUTION FOR VSCODE USERS:

Under settings search for GPG and uncheck it:

VS CODE IMAGE

Now, why would you uncheck it?

You only need this extension if using the Gnu Privacy Guard. If you don't know what it is, then you definitely do not need to worry.

However, just in case you want to know what is going on check out: https://www.gnupg.org/