When trying to access secret keys, my GPG hangs. The existing solutions suggested killing gpg-agent, but that didn't help for me. I tried debug logging (see below), but couldn't make anything out of it.

My OS is MacOS Sonoma, and I'm running gpg 2.4.3 from Homebrew.

$ pkill -9 gpg-agent

$ gpg --version
gpg (GnuPG) 2.4.3
libgcrypt 1.10.2
Copyright (C) 2023 g10 Code GmbH
License GNU GPL-3.0-or-later <https://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Home: /Users/mporkola/.gnupg
Supported algorithms:
Hash: SHA1, RIPEMD160, SHA256, SHA384, SHA512, SHA224
Compression: Uncompressed, ZIP, ZLIB, BZIP2

$ gpg --list-secret-keys --keyid-format=long --debug-level guru
gpg: enabled debug flags: packet mpi crypto filter iobuf memory cache memstat trust hashing ipc clock lookup extprog
gpg: enabled compatibility flags:
gpg: DBG: [no clock] start
gpg: using pgp trust model
  • I can't reproduce this out of the box with the same versions on macOS. Do you have a GnuPG key in your setup?
    – Kusalananda
    Commented Jan 9 at 12:27

1 Answer 1


Okay. I encountered this issue randomly after my macOS install crashed overnight 2 days ago. I am running macOS Sonoma 14.2.1. I really have no idea what happened, and I encountered this issue because my Emacs was hanging was navigating files/directories with find-file.

The command that was freezing my Emacs seemed to be:

/usr/local/bin/gpg --with-colons --no-greeting --batch --with-fingerprint --with-fingerprint --fixed-list-mode --list-keys "Frederick"


An apparent solution (downgrading gpg)

On this seemingly unrelated issue on the Doom Emacs repo, a Arch Linux user reported a hang when saving gpg files. Their solution was to install [email protected], since there seemed to be a problem with the latest 2.4.3 build. [doomemacs/doomemacs] Can't save epa encrypted org .gpg file #7589

Given that their solution was to downgrade to [email protected], I thought I'd try the same. Running the following commands seemed to just work:

brew uninstall --ignore-dependencies gnupg; # uninstall gpg
brew install [email protected]; # install [email protected]
brew link [email protected]; # link the new version of gpg to /usr/local/bin

After running those commands everything appeared to just work. The above command would no longer hang.

Getting gpg v2.4.3 to work

Before I went through this whole process of installing the working version of [email protected], when I ran the hanging command the first time, it failed on acquiring a lock on ~/.gnupg. Looking at Activity Monitor I saw there was a TON of gpg processes running. A quick killall gpg killed the processes.

I deleted the lock file at ~/.gnupg/gnupg_spawn_keyboxd_sentinel.lock. Didn't work. This is about when I proceeded to install [email protected].

BUT later I saw that there was another lock file. Namely, ~/.gnupg/public-keys.d/pubring.db.lock. I did not delete this lock file the first time.

So. Let's reinstall the latest gnupg... Before I did this, I did not delete that lock file.

  • Commands:
    brew uninstall --ignore-dependencies [email protected];
    brew install gnupg;
  • Verify gpg is stuck:
    /usr/local/bin/gpg --with-colons --no-greeting --batch --with-fingerprint --with-fingerprint --fixed-list-mode --list-keys "Frederick"
    Great!(?) It's still stuck.

If we delete the lock files now at ~/.gnupg/gnupg_spawn_keyboxd_sentinel.lock and ~/.gnupg/public-keys.d/pubring.db.lock, the above command seems to work!

Some More Questions

  • Regarding @Kusalananda comment above, I do not know if I had a GnuPG key in my setup. Maybe I did? But for the [email protected] and gnupg packages (once I got them working) I got the message:

    gpg: error reading key: No public key

    Okay... interesting.

  • What caused this though?

    • That is a GOOD question. My Emacs was working fine, and then I had that power-off event, and then it did not work any longer (due to the gpg hang).
    • gnupg was updated to 2.4.3 around 9 months ago at the time of writing. So it wasn't an upgrade issue I think. Given that this occurred after a power-off event, deals with that db .lock file, and that [email protected] did not have this problem when installed, I would wager that perhaps there was something introduced that respected that db .lock file. Just a guess...
  • From the comment above about missing a key, and the fact that I'm getting those message, perhaps that is related. I'm not sure if I had keys and they got corrupted or what. Either way, this appeared to not have been an issue (in terms of command freezing) in [email protected].

I originally posted about my issue on a different Issue in the Doom Emacs Github Issue Tracker. The user they experienced a power-off event and could no longer open files. I'm wondering if perhaps the power-off events are related to the issues we're having with gpg. They did not report any issues with gpg, but it seems like they didn't post much debug info.

[doomemacs/doomemacs] Fresh install in MacOS Ventura freezes when any file is opened #7289

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .