如何在铁轨上安装红宝石

时间:2015-08-03 05:46:45

标签: ruby-on-rails ruby

我是ruby on rails的新手,在这里我试图在Windows 7 64位上安装ruby on rails。我安装了ruby安装程序,我安装了rails。我还创建了新的应用程序文件。但是当我启动rails服务器时,它显示以下错误。

如何摆脱这些错误并开始开发我的ruby应用程序?

C:\Users\walnut\Desktop > 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.

C:\Users\walnut\Desktop > rails s
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\Desktop > gem install mysql2
Fetching: mysql2-0.3.19.gem (100%)
ERROR:  Error installing mysql2:
        The 'mysql2' 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'

C:\Users\walnut\Desktop > rails s
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.

4 个答案:

答案 0 :(得分:7)

From here

关注Instructions from the Ruby Installer Developer Kit Wiki

  1. rubyinstaller.org
  2. 下载DevKit文件
  3. 将DevKit解压缩到路径C:\ RubyXXX \ DevKit
  4. 运行cd C:\RubyXXX\DevKit
  5. 运行ruby dk.rb init
  6. 运行ruby dk.rb review
  7. 运行ruby dk.rb install

答案 1 :(得分:0)

您在哪里创建应用程序?如果查看命令行,则表明您已进入桌面。您需要将目录切换到项目文件夹以使其处于正确的上下文中。

此外,您需要安装构建工具来安装json本机扩展。

请参阅/遵循其他堆栈溢出答案的说明 - The 'json' native gem requires installed build tools

答案 2 :(得分:0)

由于错误建议您必须更新PATH以包含构建工具,也称为DevKit

如果您已经使用RailsInstaller在计算机上的rails上安装ruby,那么它已经包含在您的rails安装目录中。您现在要做的就是更新PATH以包含它。请参阅DevKit Overview on Github中的说明的第4步。

如果没有按照上述说明安装DevKit然后开始工作。

答案 3 :(得分:0)

请尝试按照此step进行操作,如果您使用x64的ruby安装程序,请使用x64 devkit。同样适用于x86。我正面临这个问题,链接给了它(安装步骤)给你节省我的时间。希望这有帮助。

p / s:如果我在Windows中正确,上面的ruby v2.2不支持更高的nokogiri,为了让事情正常运行,请使用ruby v1.9.3或v2.1.6。

检查此link是否支持nokogiri。