I have installed the termux and app and used it to install emacs on my android phone, i.e.


I then installed gpg via termux, i.e.

$ apt-get install gnupg2

However when I try to open a symmetrically encrypted .gpg file (private key) in emacs (running under termux) I get the following error:

Error while decrypting with "/usr/bin/gpg":

gpg: CAST5 encrypted data
gpg: problem with the agent: Not a typewriter
gpg: encrypted with 1 passphrase
gpg: decryption failed: No secret key

Its as though it doesn't know that I have to provide the decrypt key via the emacs minibuffer in order to open the file

I've tried various permutations of the following elisp in my .emacs file:

(require 'epa)
(setq epg-gpg-program "/usr/bin/gpg"))
;; Don't display graphic prompt in terminal
(when (not (display-graphic-p))
(setq epg-gpg-program "/usr/bin/gpg"))

but all to no avail thus far

anyone with any pointers/experience in this area gratefully received..

  • Does (setq epa-pinentry-mode 'loopback) help? – akater Dec 12 '18 at 9:37

Error while decrypting with "/usr/bin/gpg":

On Termux there is no /usr folder, so you need /data/data/com.termux/files/usr/bin/gpg (or perhaps you can just specify gpg without full path?).

Also, note that you should use gpg2 if you want to use gnupg2 - the gpg program is from gnupg version 1 (and would require apt install gnupg).

  • hmm - good spot. I've tried and can run gpg and gpg2 from the termux cmd line. So they're obviously on the PATH. I modified the .emacs file location as you suggested, just using gpg2 rather than /usr/bin/gpg2. Still coming back with same error though..curious – bph Nov 28 '16 at 15:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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