EasyPG is an Emacs package that allows you to interface with GnuPG (Gnu Privacy Guard) natively Emacs. It’s pretty handy to be able to encrypt files on your own machine for sensitive data, and the interface is largely transparent - files with the .gpg extension are automatically encrypted and decrypted for you. Nifty, eh?
According to the EmacsWiki, Easy PG is included in the more recent versions of Emacs (22+ iirc), but when I tried to save a file as .gpg, I’d get the following error in my minibuffer:
Searching for program: no such file or directory, gpg
So, I figured, cool, I guess I don’t have it installed. ‘which gpg’ and ‘locate gpg’ confirmed my suspicions, so I set out obtaining GnuPG. For OS X, there’s a pretty handy automatic installer over at MacGPG and the dmg even had an uninstaller. I ended up using homebrew (‘brew install gpg’) since that was a bit simpler.
So now here I am with a working copy of gpg, fixed up my $PATH with ‘/usr/local/bin/’ where gpg was located, and Emacs was still giving the same error! “Searching for program: no such file or directory, gpg.” I gave up a few times because I was sure I had gpg in the right paths, and everything was pointing to the right places; even opening up a shell within emacs I was able to access gpg.
As it turns out, there are some peculiarities that one might encounter when running Emacs as an application on OS X. In particular, Emacs doesn’t pick up the $PATH variable unless you tell it to, and the shell won’t read off of ~/.bashrc unless you tell it to. This apparently only occurs when running Emacs off the dock or from Spotlight or something. Since my Emacs is running from a shortcut on the dock, I finally found my solution!
Explicitly adding the path to gpg in my ~/.emacs fixed the problem as expected; joy and happiness abounded. In case you’re curious whether your exec-path has what you’re expecting, ‘C-h v exec-path’ is the command you’re looking for. And now, I can encrypt and decrypt things at will, oh boy!
(add-to-list ‘exec-path “/usr/local/bin”)
Alternatively, it seems like you can also manually set the path to gpg in the epg-gpg-program variable: (setq epg-gpg-program “/usr/local/bin/gpg”). For extra credit, I also edited /etc/profile so that the Emacs shell would pick up the proper $PATH environment too.
#/etc/profile begin
if [ -x /usr/libexec/path_helper ]; then
eval `/usr/libexec/path_helper -s`
defaults write $HOME/.MacOSX/environment PATH "$PATH"
fi
#/etc/profile end