Using Emacs' EasyPG in text terminals

There is a bug in the integration between Emacs' EasyPG and the "new" GnuPG2 that causes Emacs to not load .gpg files when running in a text terminal.  It's being worked on, apparently, but in the mean-time, here is how to fix it.

The only solution I've found that works is to install a copy of GnuPG1 concurrent with the new GnuPG2.  They can live happily side-by-side.  Once you've done that, you need to tell EasyPG to use the old program rather than the new one. Full details are on the Emacs Wiki, here it is in a nutshell:

  • You can find an RPM package of GnuPG1 for openSUSE on the openSUSE Build Service
  • Once installed, you need to customize the variable epg-gpg-program.  Either use M-x customize to set it for all future sessions, or see my code snippet below that I put in my start-up scripts.  It should be set to the value "/usr/bin/gpg1" (or wherever gpg1 is installed on your platform)
  • Now when EasyPG opens a .gpg file, it will prompt for the passphrase in the Emacs minibuffer, instead of trying to use the gpg-agent and calling the pinentry program (which causes Emacs to hang in text mode)
 

If you like to use the gpg agent and graphical pinentry programs and only want to override GnuPG2 with GnuPG1 when running Emacs in a text terminial, then you can put code like this in your Emacs start-up (mine goes in ~/.emacs.d/<username>.el because I use the Emacs Starter Kit):

(when (not (display-graphic-p))
  (setq epg-gpg-program "/usr/bin/gpg1")) ; use GnuPG1 in text terminals
Enjoy!