I am having a hard time getting GPG to work in Emacs under Windows.

The configuration options I tried:

  (setq epg-gpg-program "c:/Program Files/GNU/GnuPG/gpg2.exe")

  (setq epg-gpg-home-directory "C:/Documents and Settings/user/My Documents/.gnupg")

Upon opening a .gpg file with Emacs 25 for Windows I get the error

epg-context--make: GPG error: "no usable configuration", OpenPGP

With Emacs 24.3 the error is epa-file--find-file-not-found-function: Opening input file: Decryption failed,

What am I missing?

Do I need some special version of GnuPG?

Additional configuration options?

1 Answer 1


I had this problem and got it to work. Needed to spelunk through the code in epg.el and epg-config.el to determine what to fiddle with. This is what worked for me:

 '(epg-gpg-home-directory "c:/Users/MYUSER/AppData/Roaming/gnupg")
 '(epg-gpg-program "C:/Progra~2/gnupg/bin/gpg.exe")
 '(epg-gpgconf-program "c:/progra~2/gnupg/bin/gpgconf.exe")

My conclusions:

  • epg.el needs gpgconf.exe to determine where all the programs are
  • also needs the home directory for gnupg
  • not sure if gpg-program also needs to be explicitly set as it is present in the output of gpgconf.exe

Give it a shot.

  • Should M-: (executable-find "gpg") returns a valid path after setting these variables? Mine returns nil after setting them. And I still have the same problem as OP before and after setting them. Dec 17, 2019 at 15:07
  • 1
    Restarting Emacs puts it into effect. eval-buffer isn't enough, at least for me. Dec 17, 2019 at 15:44
  • Doesn't work. Attempting to save/encrypt a file just hangs. Emacs 29.1 or Windows 11 with gpg4win.
    – Rob N
    Dec 15, 2023 at 3:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.