I spent days to overcome this issue, when I use GPGME each time the interactive popup came up, which is not desirable for my own project. Here is the solution.
Since the GPGME::Ctx requires you the optional parameter (passwpord | passphrase_callback) you need to pass those hash keypairs as arguments:
@context = GPGME::Ctx.new(
def passfunc(obj, uid_hint, passphrase_info, prev_was_bad, fd)
io = IO.for_fd(fd, "w")
io.puts "your passphrase"
Then without the complicated gpg-agent settings, you can supress the popup. I think looking at the source code is the best way to handle this since it is obvious that there the codes requires the function as argument.
You can refer to the following link for the further information: