The problem
Reproduce the problem with the following command:
echo "test" | gpg --clearsign
If you got the error:
gpg: signing failed: Inappropriate ioctl for device
gpg: [stdin]: clear-sign failed: Inappropriate ioctl for device
Try the following solutions.
Solution 1
Execute on the terminal:
export GPG_TTY=$(tty)
Problem should be solved now.