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

我正在进行捆绑安装,所有的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. 

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

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

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

安装它并再次尝试安装gem – 也许使用选项--platform=ruby

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

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

我不是ROR的专家,但我在安装Redmine时遇到的JSON安装问题通过执行以下操作解决:

  • 在D:\ LANGS \ MinGW \ bin创建一个make.bat
  • 将此目录保留在PATH中
  • 编辑上面的make.bat并添加一行,D:\ LANGS \ MinGW \ msys \ 1.0 \ bin \ make.exe

我意识到,mingw32-make.exe从未起作用,但’D:\ LANGS \ MinGW \ msys \ 1.0 \ bin \ make.exe’工作。

注意:我的MinGW安装在D:\ LANGS \下。 请在您的特定安装中进行相应的更改。

是的,安装开发套件。 此外,您需要运行一些命令行来安装它(而不仅仅是下载和运行)。

下载它,运行它以将其提取到某个地方(永久)。 然后cd到它,运行ruby dk.rb init和ruby dk.rb install将它绑定到路径中的ruby安装。

这方面的指南在这里:

https://github.com/oneclick/rubyinstaller/wiki/Development-Kit