gpg failed to sign the data fatal: failed to write commit object [Git 2.10.0]

前端 未结 30 1985
难免孤独
难免孤独 2020-11-27 23:55

I followed few articles over the pretty attributes on Git 2.10 release note. Going through which upgraded the git to 2.10.0 and made changes to global .gitconfig

30条回答
  •  离开以前
    2020-11-28 00:40

    This started happening all of a sudden for me on Ubuntu, not sure if some recent update did it, but none of the existing issues were applicable for me (I had GPG_TTY set, tried killing the agent etc.). The standalone gpg command was failing with this error:

    $ echo "test" | gpg --clearsign
    -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA512
    
    test
    gpg: signing failed: Operation cancelled
    gpg: [stdin]: clear-sign failed: Operation cancelled
    

    I tried running gpg with --debug-all option and noticed the below output:

    gpg: DBG: chan_3 <- INQUIRE PINENTRY_LAUNCHED 27472 gnome3 1.1.0 /dev/pts/6 screen-256color -
    gpg: DBG: chan_3 -> END
    gpg: DBG: chan_3 <- ERR 83886179 Operation cancelled 
    gpg: signing failed: Operation cancelled
    

    The above indicates that there is some issue with the pinentry program. Gpg normally runs pinentry-curses for me, so I changed it to pinentry-tty (I had to aptitude install it first) and the error went away (though I no longer get the fullscreen password entry, but I don't like that anyway). To make this change, I had to add the line pinentry-program /usr/bin/pinentry-tty to ~/.gnupg/gpg-agent.conf and kill the agent with gpgconf --kill gpg-agent (it gets restarted the next time).

提交回复
热议问题