0

Whenever I try to follow this, on step 6 I enter the code and won't install, it only tells me the following below in the commandline.

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/specs.4.8.gz)

I am brand new to commandline and I have 0 idea what this means or why it won't let me install rails. Can anyone help?

I should also add when I try to check version of ruby it gives me the proper version. But when I try to check rails I get.

C:\Sites>rails -v
The system cannot find the path specified.

UPDATE

Using Windows 10

Ruby version 2.2.4

I don't know how to tell if a firewall is stopping me

Using a home network

I just tried to run this:

C:\Sites>gem update --system
ERROR:  While executing gem ... (Gem::RemoteFetcher::FetchError)
    SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (https://api.rubygems.org/specs.4.8.gz)

and

C:\Sites>gem install rails
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/specs.4.8.gz)

When I go to the rails environment configuration I noticed it doesn't show a version number for rails but shows a bat file.

ruby:
  bin:        C:/RailsInstaller/Ruby2.0.0/bin/ruby.exe
  version:    ruby 2.2.4p230 (2015-12-16 revision 53155) [i386-mingw32]

rails:
  bin:        C:/RailsInstaller/Ruby2.0.0/bin/rails.bat
  version:

4 Answers4

0

You can follow as steps below:

1. gem sources -a http://rubygems.org
2. gem install rails
Khanh Pham
  • 2,848
  • 2
  • 28
  • 36
  • Nevermind. So it installed it but now I am getting the same error whenever I do anything else and it is warning me I may be subject to a MITM attack.... –  Oct 24 '16 at 04:30
0

As a workaround you could try to replace in your Gemfile

source 'https://rubygems.org'

with

source 'http://rubygems.org'

so that the SSL connection error dissipates. This snippet of code is located at the top of your Gemfile

Note - you are getting the MITM (man in the middle) attack warning, because you are using HTTP, rather than HTTPS (which is encrypted). This should be fine, it is just a warning and unlikely that any actual attack would occur. To get rid of this warning, follow the steps Here

Or, you can simply run gem sources -a http://rubygems.org so that your gems (including the rails 5.0.0.1 gem) are downloaded via http rather than https

Although, if you want to use the encrypted download via SSL, follow this guide on GitHub that leads you through the process of installing a certificate to trust RubyGems.org

Luka Kerr
  • 4,161
  • 7
  • 39
  • 50
0

This is for fixing ssl errors in windows
1) Download certificate
2) save it to C:/RailsInstaller/Ruby2.0.0/ssl_certs/GlobalSignRootCA.pem
3) create environment variable SSL_CERT_FILE set it to C:/RailsInstaller/Ruby2.0.0/ssl_certs/GlobalSignRootCA.pem 4) then gem install rails

user2301346
  • 438
  • 3
  • 11
  • This lists Ruby2.0.0/ssl_certs/ but I am using ruby2.2.0 and I dont see a folder named ssl_certs. Do I make one? –  Oct 24 '16 at 05:09
  • create ssl_certs folder inside your Ruby2.2.0 and change environment variable accordingly – user2301346 Oct 24 '16 at 05:14
0

So I did the following and it fixed the issue (seemingly)

for Windows with PowerShell installed

Installing Windows PowerShell

Paste this 1line code in command console: (WIN + R, cmd)

powershell -Command "& {$fname='cacert.pem'; $outpath=\"$($(Get-ChildItem Env:USERPROFILE).Value)/$fname\"; Invoke-WebRequest http://curl.haxx.se/ca/$fname -OutFile \"$outpath\"; [Environment]::SetEnvironmentVariable('SSL_CERT_FILE', \"$outpath\", 'User')}"

Script will do:

  1. Download http://curl.haxx.se/ca/cacert.pem

  2. Save it as %USERPROFILE%/cacert.pem ( C:\Users\__you__\cacert.pem)

  3. Set persistent environment variable for current user SSL_CERT_FILE as %USERPROFILE%/cacert.pem