建立Rails服务器

5

我是一个Ruby的初学者,正在按照“创建新的Rails项目”进行学习。

但是我无法启动服务器。我尝试了以下操作:

  1. running rails server but got:

    Could not find gem 'tzinfo-data <>= 0> x86-mingw32' in the gems available on the machine. 
    Run 'bundle install' to install missing gems.
    
  2. running bundle install but got:

    An error occurred while installing rake (10.4.2), and Bundler cannot continue.
    Make sure that 'gem install rake -v '10.4.2'' succeeds before bundling.
    
  3. gem 'tzinfo-data' but got:

    Unknown command tzinfo-data
    
  4. gem install tzinfo-data:

    Could not find a valid gem 'tzinfo-data' <>= 0>, here is why:
    Unable to download data from...
    

我使用的是64位的Windows 8.1操作系统。


按照已接受的答案指南,tzinfo-data已解决并使用cacert.pem文件。今天,我正在尝试安装bootstrap-sass gem文件。我需要另一个.pem文件吗?

Gem::RemoteFetcher::FetchError: SSL_connect returned=1 errno=0 state=SSLv3 read
server certificate B: certificate verify failed (https://rubygems.org/gems/boots
trap-sass-3.3.1.0.gem)
An error occurred while installing bootstrap-sass (3.3.1.0), and Bundler cannot
continue.
Make sure that `gem install bootstrap-sass -v '3.3.1.0'` succeeds before
bundling.

其中一个最初的指令是 gem install rails。这个指令是否成功执行,没有出现错误?你从 gem install tzinfo-data 看到的错误信息的剩余部分是什么?来自哪里? - lurker
@lurker,错误的其余部分如下--> ... h'ttps://rubygems.org/ - SSL_connect returned=1 errno=0 state=SSLv3 read server certificate B: certificate verify failed ( h'ttps://rubygems.org/latest_specs.4.8.gz) - Roland Jegorov
好的,你刚刚扼杀了我帮助你的希望 :) 这是 Windows,伙计。使用其他操作系统,如 *nix 或 MacOS,你会很开心的。 - freeze
@freeze;谢谢,伙计。我很担心这个问题。但是难道没有办法让它在老爷爷Windows上运行吗? - Roland Jegorov
@Vlad 我不知道有哪些。只是链接?是的,当然。 - Roland Jegorov
显示剩余15条评论
1个回答

3

您遇到了常见的SSL问题。

您将看到以下错误信息:

certificate verify failed

错误信息是因为您的系统需要一个新的SSL证书。
以下是相关信息: http://railsapps.github.io/openssl-certificate-verify-failed.html 在Windows操作系统中:
尝试升级您的SSL证书。
  1. Download http://curl.haxx.se/ca/cacert.pem.

  2. Save this file anywhere you want, such as:

    C:\RailsInstaller\cacert.pem
    
  3. On the command line, tell Ruby where to find the cert file, such as:

    set SSL_CERT_FILE=C:\RailsInstaller\cacert.pem
    
  4. Retry the gem installation.

  5. If it works, that's great. If you want this to work with every project on your system, and also survive rebooting, then you can make the cert file permanent by adding the cert system-wide. To do this, use your Windows control panel.

信用和更多信息:https://gist.github.com/fnichol/867550


“Tell Ruby where to find the cert file”是什么意思?我的意思是在哪里粘贴命令?我目前已经打开了带有Ruby的命令提示符,并且它以--> C:\Sites>开头。 - Roland Jegorov
哦,是的!我按照你说的做了,输入了 "bundle install",现在正在安装。如果出现其他错误,我会更新你的。谢谢! - Roland Jegorov
Rails 服务器命令现在也可以正常工作了。非常感谢! - Roland Jegorov
谢谢。我很惊讶 - 通常一个cacert.pem文件就可以解决整个系统的问题。1. 你是否在同一系统上?2. 如果是,你是否使用相同的shell窗口?3. 如果你再次尝试“set ...”命令,然后尝试安装会发生什么?4. 你是否将证书文件添加到控制面板中?5. 如果是这样,请重新启动系统并尝试安装。 - joelparkerhenderson
哦,不好意思,看来我没有完全阅读第五点。我会按照你的建议将其添加到我的系统中。 - Roland Jegorov
显示剩余3条评论

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接