emacs org-encrypt-entry hangs when file is modified
Asked Answered
H

5

6

macos Ventura 13.4 (22F66)

GNU Emacs 28.2 (build 1, x86_64-apple-darwin22.4.0, NS appkit-2299.50 Version 13.3.1 (a) (Build 22E772610a)) of 2023-05-31

org-mode 9.5.5

installed using homebrew emacs-plus@28 formula

Updated emacs on homebrew on May 31, 2023.

Whenever I try to encrypt an org entry after the entry is changed and has to be re-encrypted, the org-encrypt-entry function hangs there and does not encrypt. This happened after an upgrade to newest emacs on homebrew.

org-decrypt-entry works just fine, I enter my symmetric password and it decrypts to the buffer.

Also, if the file does not change, and I save the file using C-x C-s, it saves to disk just fine.

It is only when the file changes and the encryption needs to be recalculated and I have to enter the symmetric password again it hangs there on 'Saving file /path/to/file/file.org'

Same behavior for M-x org-decrypt-entry

tried: M-x org-encrypt-entry

expected password entry dialog and save encrypted file to disk

Hanford answered 2/6, 2023 at 8:17 Comment(1)
similar question: emacs.stackexchange.com/q/78140/11978Disease
H
12

According to this commit, this is known to happen with GnuPG v2.4.1.

You can try to downgrade GnuPG, or

;; DO NOT USE THIS WITH SYMMETRICALLY ENCRYPTED FILES.
;; MAY CAUSE FILE CORRUPTION.
(fset 'epg-wait-for-status 'ignore)
Housman answered 2/6, 2023 at 11:7 Comment(4)
Downgraded to gnupg 2.2 and works just fine. Thanks!Hanford
Use this script: gist.github.com/sankalp-khare/94fee1727ec5d199018be225127510d2 like ./switch-gnupg.sh 2.4.0 to change to version 2.4.0 in your homebrew setup. It will also pin that version so that subsequent brew upgrade won't get you back to the latest.Abortionist
Downgrading gpg worked for me. Ignoring the wait status did not help.Twitch
The epg-wait-for-status option works for v2.4.3 (the current version of gnupg in Homebrew at time of writing).Greathearted
B
3

Same issue here. As Tianshu Wang mentioned, the problem is the current GnuPG Version 2.4.1 on mac. I've solved the problem for me by downgrading the GnuPG package on my mac.

Check the version of GnuPG:

$ brew info gpg
==> gnupg: stable 2.4.1 (bottled)
GNU Pretty Good Privacy (PGP) package
[..]

Uninstall this version

$ brew uninstall --ignore-dependencies gpg

The option --ignore-dependencies is neccessary for me, because I use pass which needs GnuPG.

Now install an older package

$ brew install [email protected]

And here we are

$ gpg --version
gpg (GnuPG) 2.2.41
[..]

To finish up, you have to tell emacs where the "new" gpg binary is located. I use Doom, so I write a line with custom-set-variables ... to ~/.config/doom/config.el.

(require 'org-crypt)
(require 'epa-file)
(custom-set-variables 
  '(epg-gpg-program "/opt/homebrew/opt/[email protected]/bin/gpg")
)
(epa-file-enable)
(org-crypt-use-before-save-magic)
(setq org-tags-exclude-from-inheritance (quote ("crypt")))
(setq org-crypt-key nil)

With ~/.config/emacs/bin/doom sync and a restart of emacs encrypting and decrypting of everything works fine.

Brister answered 5/6, 2023 at 8:17 Comment(3)
You can also use this script: gist.github.com/sankalp-khare/94fee1727ec5d199018be225127510d2 like ./switch-gnupg.sh 2.4.0 to change to version 2.4.0 in your homebrew setup. It will also pin that version so that subsequent brew upgrade won't get you back to the latest.Abortionist
Which parts of the above elisp are actually necessary for changing the gunpg version? I imagine only epg-gpg-program should be necessary?Conducive
Why do brew uninstall --ignore-dependencies gpg at all? Can't both gpg and [email protected] be installed at the same time?Conducive
E
2

The problem persists in gnupg 2.4.3

 brew info gpg
==> gnupg: stable 2.4.3 (bottled)
Euchologion answered 26/10, 2023 at 17:2 Comment(1)
can confirm issue exists with gnupg 2.4.3 on arch linuxUnmistakable
L
2

This issue is fixed as of gnupg 2.4.4. Updating the package should fix it.

For Homebrew:

brew install gnupg

For Macports:

port selfupdate
port update gnupg2
Loesceke answered 12/3 at 16:50 Comment(1)
brew unpin gnupg && brew upgrade gnupg if previously pinned.Conducive
D
0

Since the fix for Emacs+EasyPG does not seem guaranteed, I am using a custom formula from my personal Homebrew tap with a version that I know works:

brew tap pgpbpadilla/pgpb 
brew install [email protected]

I wrote a post[1] explaining a bit more of the context, it should be easier to read than my notes in the Github repo[2].

  1. https://pgpbpadilla.github.io/2023-12-08-personal-homebrew-tap
  2. https://github.com/pgpbpadilla/homebrew-pgpb
Disease answered 8/12, 2023 at 21:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.