Unable to install Rails on clean Ruby

Posted by on Jan 7, 2015 in Other

I recently set up a clean install of Ruby and wanted to add rails using the usual command line: gem install rails 1 gem install rails However, doing so generates an error relating to the SSL certificate of the RubyGems server: ERROR: Could not find a valid gem 'rails' (>= 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://api.rubygems.org/latest_specs.4.8.gz) 1234 ERROR:  Could not find a valid gem 'rails' (>= 0), here is why:          Unable to download data from https://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/latest_specs.4.8.gz) it appears that there is a (fairly longstanding) issue with the SSL certificate which prevents the download happening. Thankfully, the fix for this is very simple. As it’s the official RubyGems repository, one can simply add the URL without the secure prefix as follows: gem sources -a http://rubygems.org 1 gem sources -a http://rubygems.org You’ll get a warning that this URL isn’t secure, just accept that by hitting ‘y’ and then repeat the install command: gem install rails 1 gem install rails It should now install just fine. I wouldn’t recommend this for other sources, but for the official RubyGems repository and given the limited risk of man-in-the-middle attacks, this should suffice as a...

Read More »