简体   繁体   English

宝石无法安装滑轨

[英]Gem can't install rails

Im using Windows 8.1 on the command prompt, it returns this error, any ideas? 我在命令提示符下使用Windows 8.1,它返回此错误,有什么想法吗?

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/ gem install bundler -r --source http://rubygems.org/

Secure way: 安全方式:

Step 1 : Obtain the new trust certificate 步骤1 :获取新的信任证书

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. 我们需要下载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. 重要说明:文件必须以.pem为扩展名。 Browsers like Chrome will try to save it as plain text file. 像Chrome这样的浏览器会尝试将其另存为纯文本文件。 Ensure you change the filename to have .pem in it after you have downloaded it. 下载文件后,请确保将文件名更改为包含.pem。

Step 2 : Locate RubyGems certificate directory in your installation 步骤2 :在安装中找到RubyGems证书目录

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. 根据安装Ruby的位置,目录将有所不同。

Take for example the default installation of Ruby 2.1.5, placed in C:\\Ruby21 以Ruby 2.1.5的默认安装为例,它位于C:\\ Ruby21中

Open a Command Prompt and type in: 打开命令提示符并键入:

C:>gem which rubygems C:/Ruby21/lib/ruby/2.1.0/rubygems.rb C:> gem ruby​​gems 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 C:>启动C:\\ Ruby21 \\ lib \\ ruby​​ \\ 2.1.0 \\ ruby​​gems

This will open a Explorer window inside the directory we indicated. 这将在我们指示的目录内打开一个Explorer窗口。

Step 3 : Copy new trust certificate 步骤3 :复制新的信任证书

Now, locate ssl_certs directory and copy the .pem file we obtained from previous step inside. 现在,找到ssl_certs目录并复制从上一步中获得的.pem文件。

It will be listed with other files like GeoTrustGlobalCA.pem. 它将与其他文件(如GeoTrustGlobalCA.pem)一起列出。

DONE 完成

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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