Troubleshooting GPG sign failure
The error might look like the below:
error: gpg failed to sign the data:
[GNUPG:] KEY_CONSIDERED <REDACTED> 2
[GNUPG:] BEGIN_SIGNING H10
[GNUPG:] PINENTRY_LAUNCHED 27730 curses 1.3.2 - xterm-256color - - 501/20 0
gpg: signing failed: Inappropriate ioctl for device
[GNUPG:] FAILURE sign <REDACTED>
gpg: signing failed: Inappropriate ioctl for device
fatal: failed to write commit object
First, if there was no prompt for you to enter the password when you made a commit, that can be solved by installing pinentry.
brew install pinentry-mac
Try to commit again and if you’re still facing an issue, double check your gpg version and make sure you’re using version 2+.
gpg --version
gpg (GnuPG) 2.4.8
If you have both installed already, try the below to add it to your path:
echo "pinentry-program $(which pinentry-mac)" >> ~/.gnupg/gpg-agent.conf
then, re-start the gpg-agent by killing it. No need to start it manually, it’ll do it for you when needed.
gpgconf --kill gpg-agent
Then try to commit again. Everything should go smooth.