# Configuring GPG for use with Eclipse

For using an external GPG program with Eclipse, GPG must be configured to use a GUI pop-up dialog for user interaction, for instance when asking for key passphrases or smartcard PINs.

Standard installations of GPG such as the distributions available from GnuPG are normally set up correctly out of the box. But in some cases, GPG on a system may be configured to ask the user for passphrases and such always via a terminal (a command window). In that case, GPG cannot be used by Eclipse.

## Getting a Passphrase Dialog

In GPG, it is not the `gpg` program itself that asks for passphrases. Instead, GPG uses a "hidden" system program `gpg-agent` to manage keys, and that `gpg-agent` program in turn uses yet another program called pinentry for actually asking the user for input. When `gpg` is invoked to sign something, it starts `gpg-agent` if that isn't running already. Once started, `gpg-agent` will continue running in the background, and will be re-used by future `gpg` operations.

How GPG asks the user for passphrases is thus determined by how the `gpg-agent` is configured. There are several possible reasons why `gpg-agent` might use a terminal input instead of a GUI dialog:

Environment variable `GPG_TTY`

  The `gpg-agent` might have been started with environment variable `GPG_TTY` being set. In that case, it may be sufficient to terminate ("kill") the currently running `gpg-agent` process. When called from Eclipse, `GPG_TTY` is not set, so if the Eclipse invokes GPG the next time, the `gpg-agent` should start normally and use a GUI dialog.

  If that works, figure out where in your system `GPG_TTY` is set and do not set it to prevent the problem from re-occurring.

Fixed pinentry configuration

  The `gpg-agent` may be configured to use a particular pinentry program. This configuration is in a file `gpg-agent.conf` in the user's GPG directory, on Unix at `~/.gnupg/gpg-agent.conf`, on Windows at `%APP_DATA%/gnupg/gpg-agent.conf`. This file may contain a configuration for `pinentry-program`, which may be set to `pinentry-tty` or `pinentry-curses`. In this case, remove the line or configure a GUI pinentry explicitly, and terminate the currently running `gpg-agent` process and optionally restart it. (Otherwise it will be restarted on the next GPG operation automatically.)

Missing GUI pinentry program

  Your system may not have a pinentry for a GUI dialog installed. This should rarely happen, and if so, only with third-party packages of GPG. Install the missing pinentry programs on your system using the system's package installation tool.

Custom pinentry script

  For advanced users: some people reconfigure the GPG pinentry via `gpg-agent.conf` by setting `pinentry-program` to a custom script that decides based on the value of environment variable `PINENTRY_USER_DATA` whether to prompt via a GUI dialog or via a terminal. If you have such a setup, make sure the script uses a GUI dialog pinentry when the variable is not set. When called via Eclipse, `PINENTRY_USER_DATA` is not set.