Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

GitHub Desktop: error: cannot run gpg: No such file or directory #675

Open
balupton opened this issue May 16, 2016 · 13 comments
Open

GitHub Desktop: error: cannot run gpg: No such file or directory #675

balupton opened this issue May 16, 2016 · 13 comments
Labels
authentication SMS, 2FA, MFA, WebAuthn, passwords, and other related authentication schemes WIP

Comments

@balupton
Copy link

balupton commented May 16, 2016

So according to https://github.com/blog/2144-gpg-signature-verification I setup GPG and my signing key, and it seems to be working via the terminal. However, GitHub Desktop doesn't like it.

Whenever I click the "Commit to master" button on GitHub Desktop on OSX, I get:

error: cannot run gpg: No such file or directory
error: could not run gpg.
fatal: failed to write commit object
 (128)

Using GitHub Desktop version Beset by Computers (220) on OS X 10.11.4 (15E65)

$ git --version
git version 2.8.2

$ gpg --version
gpg (GnuPG) 1.4.20
Copyright (C) 2015 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: ~/.gnupg
Supported algorithms:
Pubkey: RSA, RSA-E, RSA-S, ELG-E, DSA
Cipher: IDEA, 3DES, CAST5, BLOWFISH, AES, AES192, AES256, TWOFISH,
        CAMELLIA128, CAMELLIA192, CAMELLIA256
Hash: MD5, SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

$ git config --list  # truncated
user.signingkey=MYKEYCODE
commit.gpgsign=true
@balupton
Copy link
Author

Tracked here too it seems http://stackoverflow.com/q/36941533/130638

balupton added a commit to bevry/dorothy that referenced this issue May 16, 2016
@balupton
Copy link
Author

balupton commented May 16, 2016

Solved it via workaround.

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 (why this is needed I have no idea):

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

I've automated this via the setup-git command from the dotfiles I use:

https://github.com/bevry/dotfiles

@mathieudutour
Copy link

mathieudutour commented Jul 15, 2016

GitHub got back to me and said that some users also need to use (why this is needed I have no idea):

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

Without it, I had this error: cannot open /dev/tty': device not configured

@freak4pc
Copy link

freak4pc commented Jul 21, 2016

Any way to get this working with Passphrase?
Getting this error after using the two commands provided by @balupton

gpg: Sorry, no terminal at all requested - can't get input
error: gpg failed to sign the data
fatal: failed to write commit object
 (128)

@MikeLund
Copy link

Try out this process out @freak4pc, works well for me: https://gist.github.com/bmhatfield/cc21ec0a3a2df963bffa3c1f884b676b

@ghost
Copy link

ghost commented Jan 5, 2017

I followed guides multiple times, and in the end, my mistake was inputting singingkey instead of signingkey. I didn't just run the command above because I generate my dotfiles so if I ran the command, it would just get overwritten the next time I updated. So if all else fails, double check your spelling.

23j51di

I will also note that I was unable to generate a key for a while because I added those conf files in prior to generating the key. Something about them prevented the key from being generated for me. So I did the key first, THEN added the conf files.

Edit: so it's April 1 now and I changed my email again and went through this process one more time. Turns out I did everything right the first time, I just had to restart my computer. So, try a restart if you're still failing.

@MuhsinFatih
Copy link

MuhsinFatih commented Jun 11, 2017

So running the following solved the problem:

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

In my case as I use gpg2 it was:

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

@BoGnY
Copy link

BoGnY commented Jan 5, 2018

This is my gist that explain how to enable auto-signing of Git commits for EVERY programs that don't support it natively..
It's specifically for Windows systems!!

@NatoBoram
Copy link

I tried no-tty, but then I get Git: gpg: Sorry, no terminal at all requested - can't get input.

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

gpg-agent
gpg-agent[5485]: gpg-agent running and available

cat ~/.gnupg/gpg-agent.conf 
allow-preset-passphrase
default-cache-ttl 28800
pinentry-program /usr/bin/pinentry-gnome3

jwalgran added a commit to jwalgran/dotfiles that referenced this issue Jun 15, 2018
After pulling the latest develop branch and upgrading packages, magit started
complaining about not being able to find emacsclient and not being able to gpg
sign commits.

The changes in this commit were made based on some Googling

magit/magit#2318
isaacs/github#675
@TPS TPS added authentication SMS, 2FA, MFA, WebAuthn, passwords, and other related authentication schemes WIP labels Feb 28, 2019
@freak4pc
Copy link

freak4pc commented Mar 1, 2019

Well, that's not really a solution, that entirely turns off Verified Commits :)

@bobbysiagian00
Copy link

I highly suggest to follow this gist,
then everything goes well.

note: for several cases, if you can't generate the key, ensure you have to remove no-tty line from ~/.gnupg/gpg.conf

@jstiers
Copy link

jstiers commented Apr 23, 2020

Solved it via workaround.

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 (why this is needed I have no idea):

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

Awesome, thank you !

@gitmatheus
Copy link

Solved it via workaround.

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 (why this is needed I have no idea):

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

Worked for me. Thanks!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
authentication SMS, 2FA, MFA, WebAuthn, passwords, and other related authentication schemes WIP
Projects
None yet
Development

No branches or pull requests