How to resolve "gpg: command not found" error during RVM installation?

147,734

Solution 1

GnuPG (with binary name gpg) is an application used for public key encryption using the OpenPGP protocol, but also verification of signatures (cryptographic signatures, that also can validate the publisher if used correctly). To some extend, you could say it's for OpenPGP what OpenSSL is for X.509 and TLS.

Unlike most Linux distributions (which make heavy use of GnuPG for ensuring untampered software within their package repositories), Mac OS X does not bring GnuPG with the operating system, so you have to install it on your own.

Possible sources are:

  • Package manager Homebrew: brew install gnupg gnupg2
  • Package manager MacPorts: sudo port install gnupg gnupg2
  • Install from GPGTools, which also brings GUI applications and integration in Apple Mail

Solution 2

As the instruction said "might need gpg2"

In mac, you can try install it with homebrew

$ brew install gpg2 

Solution 3

On Mac OSX 10.15, Even after installing gpg, i was getting gpg2 command not found

$ brew install gnupg gnupg2
Warning: gnupg 2.2.23 is already installed and up-to-date
To reinstall 2.2.23, run `brew reinstall gnupg`

$ gpg2 --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
-bash: gpg2: command not found

Instead, this worked for me

$ gpg --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

Solution 4

This worked for me

$brew install gnupg

Solution 5

Here are the steps to install RVM.

Step 1: Install gpg or gpg2 (both work)

brew install gpg

Step 2: Install GPG keys used to verify installation package:

gpg --keyserver hkp://pgp.mit.edu --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB

If you encounter problem with the key server above, try a different one.

  • hkp://ipv4.pool.sks-keyservers.net
  • hkp://pgp.mit.edu
  • hkp://keyserver.pgp.com

Step 3: Install RVM

\curl -sSL https://get.rvm.io | bash -s stable

Check out the Security page if you still run into problems.

Share:
147,734

Related videos on Youtube

JDillon522
Author by

JDillon522

I love learning the science behind the magic.

Updated on August 08, 2022

Comments

  • JDillon522
    JDillon522 almost 2 years

    I have a new mac pro (OS X 10.9.5) that I get to set up from scratch. I want to install RVM and the first thing it says to do is:

    Install mpapis public key (might need gpg2 and or sudo)

    gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
    

    When I tried I got:

    gpg --keyserver hkp://keys.gnupg.net --recv-keys D39DC0E3
    zsh: command not found: gpg
    

    I've tried to find a good guide on how to overcome this that also looks trustworthy but I've had no luck.

    Can someone explain what gpg is, why I dont already have it, and how do I get it the right way.

    • ofrommel
      ofrommel over 9 years
      did you try "gpg" in Google? It's public key encryption, and you need to install the appropriate tool either by hand or from Brew or Macports. Also not exactly a StackOverflow question.
    • Harry Yu
      Harry Yu almost 3 years
      Hi guys, if you are trying to set up RVM in 2021 or later and found this issue, after you installed by brew and run the command on RVM again, you will see "gpg: keyserver receive failed: No name" error, that's because the SKS Keyserver Network is being deprecated. You need to change the keyserver to another one, like run "gpg --keyserver keyserver.ubuntu.com --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB". From <stackoverflow.com/a/68132500>.
  • dwsolberg
    dwsolberg over 9 years
    If you don't have homebrew, you can install it on Mac OS X with the command: ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/in‌​stall)" See (coolestguidesontheplanet.com/…) for more information.
  • Brian Zelip
    Brian Zelip almost 9 years
    I had the exact same issue as the original question asked by JDillon522. To install RVM I only installed gpg2. This answer helped me to additionally install gpg.
  • Brian Zelip
    Brian Zelip almost 9 years
    A user will also need to install gpg in addition to gpg2, see the answer by Jens Erat.
  • ProGirlXOXO
    ProGirlXOXO over 8 years
    brew install gnupg gnupg2 -> Error: The brew link step did not complete successfully The formula built, but is not symlinked into /usr/local Could not symlink share/man/man8/addgnupghome.8 /usr/local/share/man/man8 is not writable.
  • Jens Erat
    Jens Erat over 8 years
    This sounds like some other package/package manager changed permissions for that folder. brew doctor might indicate the problem and suggest solutions, but generally I'd rather ask for help at Ask Different, using a package manager is rather off topic on Stack Overflow.
  • foamcow
    foamcow over 7 years
    Installing via homebrew didn't seem to work for me. Despite the process completing without a problem the gpg command was still unavailable. I ended up using gpg tools which made the command available.
  • Jens Erat
    Jens Erat over 7 years
    I guess that something wrent wrong setting up your $PATH variable.
  • taranjeetsapra
    taranjeetsapra about 7 years
    how to install gnupg gnupg2 on windows as brew installer is for mac only?
  • Jens Erat
    Jens Erat about 7 years
    You're probably best off with the GPG4Win distribution of GnuPG, which also includes an installer. If you still have issues with gpg not being found, make sure your %PATH% variable is set up properly.
  • Brian Ball
    Brian Ball over 4 years
    brew doctor worked to help me get it working after I was getting the gpg command not found.
  • C13L0
    C13L0 over 3 years
    Seconding that running with keyserver flag worked!
  • joedragons
    joedragons over 2 years
    Got 'gpg: keyserver receive failed: No name' with command as given. Tried a different keyserver and worked.
  • Denis V
    Denis V over 2 years
    Yep, first 2 key servers from sks-keyservers.net don't work for me now. 3rd one from rvm.io/rvm/security worked: gpg --keyserver hkp://pgp.mit.edu --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
  • Frank Guo
    Frank Guo over 2 years
    Had the same problem and the gpg one worked!