Resolving error in installing any gem by Ruby

After installing the Ruby installer you might need to install some gems. For example, if you are developing with RedHat OpenShift you want to install ‘rhc’ gem to access remote files on OpenShift. To install ‘rhc’ you would run the following command.

>gem install rhc

But you might get the following error, especially on a Windows machine.

>gem install rhc
ERROR:  Could not find a valid gem 'rhc' (>= 0), here is why:
          Unable to download data from https://rubygems.org/ - SSL_connect retur
ned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (
https://rubygems.global.ssl.fastly.net/quick/Marshal.4.8/rhc-1.15.6.gemspec.rz)
ERROR:  Possible alternatives: rhc

Solution

The problem is due to running over a secure (https) connection to rubygems.org. Look at the help for “gem sources –h”, remove the https version and add http://rubygems.org

Run the following commands to do this.

>gem sources --remove https://rubygems.org/
>gem sources --add http://rubygems.org/

And now you can easily install any gem.

Click here to read more about programming and other technologies.

Share your love
Muhammad Jawaid Shamshad
Muhammad Jawaid Shamshad
Articles: 128

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.