Error in installing json gem for ruby in windows

2019-08-14 17:34发布

问题:

While I am trying to create the new rails project, I face to error that is related to the lack of json gem.

When I try to install json gem, this error happens:

Temporarily enhancing PATH to include DevKit...
Building native extensions.  This could take a while...
ERROR:  Error installing json:
        ERROR: Failed to build gem native extension.

    C:/Ruby22-x64/bin/ruby.exe extconf.rb
creating Makefile

make "DESTDIR=" clean

make "DESTDIR="
generating generator-x64-mingw32.def
compiling generator.c
In file included from c:/Ruby22-x64/include/ruby-2.2.0/ruby/ruby.h:29:0,
                 from c:/Ruby22-x64/include/ruby-2.2.0/ruby.h:33,
                 from ../fbuffer/fbuffer.h:5,
                 from generator.c:1:
c:/Ruby22-x64/include/ruby-2.2.0/ruby/defines.h:26:19: fatal error: stdio.h: No such file or directory
compilation terminated.
make: *** [generator.o] Error 1

make failed, exit code 2

Gem files will remain installed in C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/json-1.8.3 for inspection.
Results logged to C:/Ruby22-x64/lib/ruby/gems/2.2.0/extensions/x64-mingw32/2.2.0/json-1.8.3/gem_make.out

回答1:

If you want to install Ruby 2 (or greater) on Windows 7 (64 bit), you need to install DevKit 64 bit as well. Your Devkit has to be compatible with your operating system.

So, make sure you installed the correct Ruby and the compatible Devkit on your system.

See this tutorial for more information.



回答2:

There was a group of gems which are dependent together. So, I had to install step by step.

As I did it based on error messages and one by one, I forgot to make a note about the steps.