gpg: problem with the agent: Permission denied
Solution 1:
Try using the PIN entry mode of loopback:
gpg --decrypt --pinentry-mode=loopback <file>
I can replicate your issue on my Linux system when I try GPG with a terminal su:
$ gpg --decrypt example.gpg
gpg: AES256 encrypted data
gpg: problem with the agent: Permission denied
gpg: encrypted with 1 passphrase
gpg: decryption failed: No secret key
The solution that works for me:
$ gpg --decrypt --pinentry-mode=loopback example.gpg
hello world
You may also want to verify that your GPG is up to date:
$ gpg --version
gpg (GnuPG) 2.2.4
libgcrypt 1.8.1
...