简体   繁体   中英

Gem can't install rails

Im using Windows 8.1 on the command prompt, it returns this error, any ideas?

c:\Sites\railsbridge>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 retur
ned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed (
https://api.rubygems.org/latest_specs.4.8.gz)

c:\Sites\railsbridge>

我遇到了这个问题,似乎是由于ruby installer版本(2 ...)导致的,我尝试了版本1.9.3,此问题已解决。

There are two ways:

Secure and Unsecure

Unsecure Way:

gem install bundler -r --source http://rubygems.org/

Secure way:

Step 1 : Obtain the new trust certificate

If you've read the previous sections, you will know what this means (and shame on you if you have not).

We need to download AddTrustExternalCARoot-2048.pem.

Use the above link and place/save this file somewhere you can later find easily (eg. your Desktop).

IMPORTANT: File must have .pem as extension. Browsers like Chrome will try to save it as plain text file. Ensure you change the filename to have .pem in it after you have downloaded it.

Step 2 : Locate RubyGems certificate directory in your installation

In order for us copy this file, we need to know where to put it.

Depending on where you installed Ruby, the directory will be different.

Take for example the default installation of Ruby 2.1.5, placed in C:\\Ruby21

Open a Command Prompt and type in:

C:>gem which rubygems C:/Ruby21/lib/ruby/2.1.0/rubygems.rb

Now, let's locate that directory. From within the same window, enter the path part up to the file extension, but using backslashes instead:

C:>start C:\\Ruby21\\lib\\ruby\\2.1.0\\rubygems

This will open a Explorer window inside the directory we indicated.

Step 3 : Copy new trust certificate

Now, locate ssl_certs directory and copy the .pem file we obtained from previous step inside.

It will be listed with other files like GeoTrustGlobalCA.pem.

DONE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM