简体   繁体   English

从命令提示符运行 rails 应用程序时出错

[英]Error while running an rails application from command prompt

I have rails 4.1.8 with ruby version "ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32]" in windows 8. I followed this tutorial to install ruby on rails-" http://installfest.railsbridge.org/installfest/windows ". I have rails 4.1.8 with ruby version "ruby 2.1.5p273 (2014-11-13 revision 48405) [i386-mingw32]" in windows 8. I followed this tutorial to install ruby on rails-" http://installfest. railsbridge.org/installfest/windows ”。 Now whenever I run any rails app I am getting this error-现在,每当我运行任何 Rails 应用程序时,我都会收到此错误-

Fetching source index from https://rubygems.org/
Retrying source fetch due to error (2/3):Bundler::Fetcher::CertificateFailureError 
Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification. For information about OpenSSL certificates, see bit.ly/ruby-ssl. To connect without using SSL, edit your Gemfile sources and change 'https' to 'http'.
Retrying source fetch due to error (3/3): Bundler::Fetcher::CertificateFailureError Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification. For information about OpenSSL certificates, see bit.ly/ruby-ssl. To connect without using SSL, edit your Gemfile sources and change 'https' to 'http'.
Could not verify the SSL certificate for https://rubygems.org/.
There is a chance you are experiencing a man-in-the-middle attack, but most likely your system doesn't have the CA certificates needed for verification. For information about OpenSSL certificates, see bit.ly/ruby-ssl. To connect without using SSL, edit your Gemfile sources and change 'https' to 'http'.

Shall I change the https to http?我应该将 https 更改为 http 吗? Is it secure?它安全吗?

As the error message says: 如错误消息所述:

For information about OpenSSL certificates, see bit.ly/ruby-ssl. 有关OpenSSL证书的信息,请参见bit.ly/ruby-ssl。

bit.ly/ruby-ssl points to http://railsapps.github.io/openssl-certificate-verify-failed.html which has the explanation for what is happening, and suggestions on how to fix it. bit.ly/ruby-ssl指向http://railsapps.github.io/openssl-certificate-verify-failed.html ,其中包含发生情况的解释以及如何修复的建议。

Changing https to http in source 'http://rubygems.org' is one of the recommended workarounds. 建议在source 'http://rubygems.org'中将https更改为http ,这是建议的解决方法之一。

There is a windows specific solution at the bottom which recommends downloading a cacert.pem for RailsInstaller 底部有一个Windows特定的解决方案,建议为RailsInstaller下载cacert.pem

This can be solved by running gem update --system 这可以通过运行gem update --system来解决

I ran into the same problem myself not too long ago and that fixed it for me. 我不久前遇到了同样的问题,这对我来说已经解决了。

只需转到根目录中的gem文件,然后将最上面一行的“ https”更改为“ http”即可。

Changing https to http is just asking for trouble, especially if you're on a production machine. 将https更改为http只会带来麻烦,特别是如果您在生产机器上。 The security was put there for a reason. 安全被放在那里是有原因的。

There are many solutions to list, all the way from updating your certs, updating your openssl, to rebuilding your ruby against an updated cert directory etc. 从更新证书,更新openssl到根据更新的证书目录重建ruby等所有方法,一路列出。

But the one solution that covers all bases is to nuke your rvm: 但是,涵盖所有基础的一种解决方案是核对rvm:

rvm implode
brew uninstall openssl --force
# now reinstall rvm for your system
# install ruby 2.3.1 via rvm (at this point RVM will install openssl 1.0.2j via homebrew)
# issue should be fixed.

Solution taken from https://github.com/rubygems/rubygems/issues/1758 . 来自https://github.com/rubygems/rubygems/issues/1758的解决方案。

I too had the same problem. 我也有同样的问题。 As said by others earlier. 正如其他人先前所说。 The simplest solution would be 最简单的解决方案是

  • Download the cacert.pem file from cacert.pem download link . cacert.pem下载链接下载cacert.pem文件。
  • Save this file to " C:\\RailsInstaller\\cacert.pem ". 将此文件保存到“ C:\\ RailsInstaller \\ cacert.pem ”。 Incase you are trying this for redmine you can move it to the redmine root folder. 如果您要尝试使用Redmine,可以将其移至Redmine根文件夹。 In my case I'm using bitnami redmine stack, I moved the file to "C:\\Bitnami\\redmine-3.3.2-2\\apps\\redmine\\htdocs\\ssl_certs" 在我使用bitnami redmine堆栈的情况下,我将文件移动到“ C:\\ Bitnami \\ redmine-3.3.2-2 \\ apps \\ redmine \\ htdocs \\ ssl_certs”
  • Now set a system environment variable as, 现在将系统环境变量设置为

     Variable Name: SSL_CERT_FILE Value: C:\\RailsInstaller\\cacert.pem [My value was C:\\Bitnami\\redmine-3.3.2-2\\apps\\redmine\\htdocs\\ssl_certs] 

This worked for me. 这对我有用。

Turning off my VPN solves the problem关闭我的 VPN 可以解决问题

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

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