The Error Link to heading

When you try to decrypt something using gpg and if gpg is reading the input from a pipe, like this echo "something encrypted" | gpg --decrypt, it fails with the following error

gpg: public key decryption failed: Inappropriate ioctl for device
gpg: decryption failed: Inappropriate ioctl for device

The solution Link to heading

This happens because GPG does not know where to read the input from, simply set the env variable GPG_TTY.

export GPG_TTY=$(tty)

If you use GPG more often and if you would like to persist this environment variable, append it to your ~/.zshrc or ~/.bashrc