无法使用Windows在rails中安装JSON gem

Ray*_* A. 12 ruby gem ruby-on-rails

我正在进行捆绑安装,所有的Gems工作正常,除了JSON,当它到达JSON gem我收到此错误.

Installing json (1.6.1) with native extensions c:/Ruby192/lib/ruby/site_ruby/1.9.1/rubygems/installer.rb:55
    2:in `rescue in block in build_extensions': ERROR: Failed to build gem native extension. (Gem::Installer::E
    xtensionBuildError)

            c:/Ruby192/bin/ruby.exe extconf.rb
    checking for re.h... *** extconf.rb failed ***
    Could not create Makefile due to some reason, probably lack of
    necessary libraries and/or headers.  Check the mkmf.log file for more
    details.  You may need configuration options.
Run Code Online (Sandbox Code Playgroud)

有什么可能导致这个错误的想法吗?

knu*_*nut 16

您正在使用Windows,因此RubyInstaller开发工具包可以帮助您:http://rubyinstaller.org/add-ons/devkit/

devkit安装了一个C编译器(以及其他一些东西)来编译C编写的部分.

安装它并再次尝试安装gem - 也许有选项--platform=ruby.

有关详细信息,访问https://github.com/oneclick/rubyinstaller/wiki/Development-Kit

  • 这是正确的答案,但一定要做gem update --system,否则你仍然会遇到rubyinstaller的问题 (5认同)
  • 甚至还有针对devkit的Chocolatey NuGet安装程序!http://chocolatey.org/packages/ruby.devkit (2认同)

War*_*Hog 4

那是因为这个 gem 使用一段用 C 编写的代码。为了正常工作,你需要在你的机器上安装 c 编译器。作为一种方法,尝试使用纯 Ruby 编写的json_pure