85

Trying to commit my changes by using GitHub Desktop and getting this:

enter image description here

error: cannot run gpg: No such file or directory

error: could not run gpg.

fatal: failed to write commit object (128)

Firstly that not worked for terminal too and i create gpg-key and plugged in to my GitHub Account Now it's working well in Terminal but Desktop version still not working.

In Oficial doccumentation for GitHub Desktop i found some notation:

Note: GitHub Desktop does not support GPG signing.

6
  • What does git status show you when you see this error coming from GitHub Desktop? Apr 29, 2016 at 15:02
  • Showing all changes, i used Win os before just trying to set mac and get this trouble... Apr 29, 2016 at 15:09
  • Did you configure GitHub Desktop on your Mac? Apr 29, 2016 at 15:10
  • Yes, Logged and Clone my Repo May 2, 2016 at 14:38
  • I have the same issue. If work with git from console all ok. But if use GitHub app I have same error. Do you resolve issue? May 9, 2016 at 12:50

4 Answers 4

199

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
5
  • 5
    I've tried running both of these lines but still getting this error. Anyone else having problems? Jun 26, 2018 at 16:05
  • Hi @captDaylight. I got the same issue. Do u have solution in this case? Dec 31, 2018 at 9:19
  • 2
    FWIW, I was having this problem on vscode (Visual Studio Code), and the same solution fixed it. 💕
    – chesterbr
    Mar 22, 2019 at 20:22
  • 1
    After installing big sur, git commit did not work from within vs code and complained about gpg: no such file or directory. This solved it for me.
    – Raunaq
    Nov 25, 2020 at 5:13
  • 9
    git config --global gpg.program $(which gpg) alone fixed my issue
    – Amir
    Jul 16, 2021 at 0:46
12

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.

0
10

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 = yogesh.jadhav@xxx.com.au
    name = jadhavy
    signingkey = xxx
[credential]
    helper = osxkeychain
[gpg]
    program = /usr/local/MacGPG2/bin/gpg2
[commit]
    gpgsign = true
[core]
    autocrlf = input
3

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 about it.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.