繁体   English   中英

在Rails上的ruby中启动服务器时出错

[英]Error while starting server in ruby on rails

我是Ruby on Rails的新手,在这里,我尝试在64位Windows 7的Rails上安装Ruby。

在运行命令rails new app_name ,我先执行了cd app_name ,然后安装了rails server随后在命令提示符下出现以下错误。

我该如何解决这个错误?

Could not find gem 'mysql2 (>= 0) x64-mingw32' in any of the gem sources listed
in your Gemfile or available on this machine.
Run `bundle install` to install missing gems.

如果我运行捆绑安装,我会得到

C:\Users\walnut>bundle install
Fetching gem metadata from https://rubygems.org/............
Fetching version metadata from https://rubygems.org/...
Fetching dependency metadata from https://rubygems.org/..
Resolving dependencies.................
Using rake 10.4.2
Using i18n 0.7.0
Installing json 1.8.3 with native extensions

Gem::InstallError: The 'json' native gem requires installed build tools.

Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
An error occurred while installing json (1.8.3), and Bundler cannot continue.
Make sure that `gem install json -v '1.8.3'` succeeds before bundling.

在这里您可以尝试以下解决方案:

  1. 安装rubyinstaller-1.9.3(我确实尝试过使用最新版本,但是遇到一些问题,请先尝试使用此安装程序- 在此处下载)
  2. 安装DevKit( 在此处下载)-找到For use with Ruby 1.8.7 and 1.9.3:在我们安装ruby-1.9.3时,这些下载页面中的文本。
    • 您可以按照以下步骤进行devKit安装
    • 遵循此:
      • 下载后,运行它以将其解压缩到某个位置(永久)。 然后将其安装到CD,运行ruby dk.rb initruby dk.rb install将其绑定到路径中的ruby安装。
  3. 之后,输入gem install rails --no-ri --no-rdoc
  4. 完成上述所有步骤后,您可以在任何地方使用此命令创建rails项目rails new yourProject
  5. 如果出现错误,例如"An error occurred while installing rake (*any version), and Bundler cannot continue." ,请参考此解决方案或执行以下步骤:
    • 下载AddTrustExternalCARoot-2048.pem ,并将其放置在ruby安装文件夹中,通常类似于以下路径C:\\Ruby193\\lib\\ruby\\site_ruby\\1.9.1\\rubygems\\ssl_certs
  6. 再次尝试键入rails new yourProject (上一个失败)。
  7. 完成,通常有关捆绑安装的错误已经消失。 祝我朋友好运。
  8. 最后,输入yourProject目录,然后运行rails server

我在Windows平台上首次安装时也遇到困难,希望能有所帮助。 请注意,如果您使用的不是默认数据库,而是通过Rails(sqlite3)使用mysql, postgresql, etc ,则需要安装正确的gem才能正常工作。 只需运行gem install theRightGemForDatabase

暂无
暂无

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

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