Skip to content
This repository was archived by the owner on Nov 18, 2021. It is now read-only.
This repository was 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

Description

@balupton

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

Activity

  1. balupton commented on May 16, 2016

    @balupton
    Author

    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

  2. mathieudutour commented on Jul 15, 2016

    @mathieudutour

    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

  3. freak4pc commented on Jul 21, 2016

    @freak4pc

    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)
    
  4. MuhsinFatih commented on Jun 11, 2017

    @MuhsinFatih

    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)
    
  5. BoGnY commented on Jan 5, 2018

    @BoGnY

    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!!

  6. NatoBoram commented on Apr 17, 2018

    @NatoBoram

    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
  7. added
    authentication
    on Feb 28, 2019
  8. freak4pc commented on Mar 1, 2019

    @freak4pc

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

  9. bobbysiagian00 commented on Jul 29, 2019

    @bobbysiagian00

    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

  10. jstiers commented on Apr 23, 2020

    @jstiers

    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 !

  11. gitmatheus commented on Sep 30, 2020

    @gitmatheus

    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 join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    WIPauthentication

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions