gpg: connecting dirmngr failed: IPC connect call failed

22 Mar 2016 in TIL

When trying to run --recv-key I was running into issues where dirmngr didn't exist. As it turns out, it's the same issue I was having where gpg-agent couldn't start/

Given the following error message:

bash
$ gpg --recv-key 0xDEADBEEF
gpg: DBG: locking for '/home/michael/.gnupg/gnupg_spawn_dirmngr_sentinel.lock' done via O_EXCL
gpg: connecting dirmngr at '/home/michael/.gnupg/S.dirmngr' failed: IPC connect call failed
gpg: keyserver receive failed: No dirmngr

The fix is to redirect the socket to somewhere writeable.

bash
$ printf '%%Assuan%%\nsocket=/dev/shm/S.dirmngr\n' > ~/.gnupg/S.dirmngr