Cannot install JSON gem in rails using windows

依然范特西╮ 提交于 2019-12-17 06:45:13

问题


I am doing a bundle install and all of the gems work fine except JSON when it get to the JSON gem I receive this error.

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.

Any idea on what could be causing this error?


回答1:


You are working with Windows, so the RubyInstaller Development Kit may help you: http://rubyinstaller.org/add-ons/devkit/

The devkit installs a C-compiler (and some other stuff) to compile C-written parts.

Install it and try again to install the gem - perhaps with option --platform=ruby.

Details can be found at https://github.com/oneclick/rubyinstaller/wiki/Development-Kit




回答2:


That's because this gem using a piece of code written on C. For working properly you need c compiler installed on your machine. As a way, try to use json_pure written on pure Ruby




回答3:


I'm not an expert in ROR, but the JSON installation issue which I got while installing Redmine was resolved by doing the following:

  • Create a make.bat at D:\LANGS\MinGW\bin
  • Keep this directory in the PATH
  • Edit the above make.bat and add a line, D:\LANGS\MinGW\msys\1.0\bin\make.exe

What I realized is, mingw32-make.exe never worked, but 'D:\LANGS\MinGW\msys\1.0\bin\make.exe' worked.

Note: My MinGW installation is under D:\LANGS\ . Please make the changes accordingly in your specific installation.




回答4:


Yes, install the development kit. Also, You will need to run a few command lines to install it (not just simply download and run).

Download it, run it to extract it somewhere (permanent). Then cd to it, run ruby dk.rb init and ruby dk.rb install to bind it to ruby installations in your path.

A guide for that is here:

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



来源:https://stackoverflow.com/questions/7780756/cannot-install-json-gem-in-rails-using-windows

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!