16

I installed the gnupg2 formula from Homebrew successfully and can run gpg2 from the command line. However, certain programs such as git expect to run gpg rather than gpg2.

I resolved this problem by using what I feel like is a dirty hack: a symlink of gpg2 to gpg:

ln -s /usr/local/bin/gpg2 /usr/local/bin/gpg

Is there a more proper way to do this? Should I just settle for installing the gnupg formula?

Sort of looking for something like this for OSX: How to set gpg2 as default implementation of gpg on debian?.

carloabelli
  • 573
  • 3
  • 7
  • 19

2 Answers2

29

Be aware that GnuPG 2 sometimes has slightly different ouput, especially with GnuPG 2.1. This will usually not be a problem, but in rare cases weird things might happen.

Individually configure the gpg binary to be used per application. For example, git has the gpg.program option. From man gpg-config:

gpg.program

Use this custom program instead of "gpg" found on $PATH when making or verifying
a PGP signature. The program must support the same command-line interface as
GPG, namely, to verify a detached signature, "gpg --verify $file - <$signature"
is run, and the program is expected to signal a good signature by exiting with
code 0, and to generate an ascii-armored detached signature, the standard input
of "gpg -bsau $key" is fed with the contents to be signed, and the program is
expected to send the result to its standard output.

Use git config --global gpg.program gpg2 to choose GnuPG 2 for your user, or replace --global with --system to change the setting for all users.

Jens Erat
  • 17,507
  • 14
  • 61
  • 74
  • Works perfectly for git! Thanks. Do you know an easy way to get zsh completion for gpg2? – carloabelli Mar 08 '15 at 22:41
  • 1
    I'm using bash only, I cannot help you with that. But this seems to be an excellent additional question to ask. I'd consider going to the [Unix&Linux](http://unix.stackexchange.com/) Stack Exchange though, I guess you will find more people familiar with zsh over there than here on Super User. Don't be scared of mentioning OS X there (if sticking to the command line), in the end it's just another Unix system. – Jens Erat Mar 08 '15 at 22:45
  • 1
    Thank you for your help! For reference I asked the question here: http://unix.stackexchange.com/questions/188945/zsh-gpg2-autocompletion. – carloabelli Mar 08 '15 at 22:51
0

Instead of the symlink maybe you can try this?

brew link --overwrite gnupg
user9869932
  • 161
  • 1
  • 5