Cannot install JSON gem in rails using windows

2020-01-26 08:18发布

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?

4条回答
太酷不给撩
2楼-- · 2020-01-26 09:08

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

查看更多
SAY GOODBYE
3楼-- · 2020-01-26 09:13

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

查看更多
Lonely孤独者°
4楼-- · 2020-01-26 09:14

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.

查看更多
乱世女痞
5楼-- · 2020-01-26 09:22

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

查看更多
登录 后发表回答