When the DISPLAY env variable is set but empty gpgme can construct an invalid gpg command in engine-gpg.c$702 and error out in unexpected ways. This can be easily reproduced when running the test suite with DISPLAY='' where it fails with different errors, GPGME: Invalid crypto engine, GnuPG: General error, GPGME: No data... Enabling debug shows this:
_gpgme_io_read: check: [GNUPG:] FAILURE option-parser 33554433<LF>
(...)
_gpgme_io_read: check: gpg: missing argument for option "--display="<LF>
I think gpgme could handle this situation or at least it should explicitly throw and error or find some way to pass the empty string to gpg. I'm attaching a patch here to skip adding --display= if its empty in a similar way as it was done for gnupg in 0076bef2026a. Let me know if this is a valid approach.
TIA