在Windows中为ruby安装json gem时出错

时间:2015-10-12 15:27:53

标签: ruby-on-rails ruby json rubygems

当我尝试创建新的rails项目时,我面临与缺少json gem相关的错误。

当我尝试安装json gem时,会发生以下错误:

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

2 个答案:

答案 0 :(得分:0)

如果要在Windows 7(64位)上安装Ruby 2(或更高版本),则还需要安装DevKit 64位。您的Devkit必须与您的操作系统兼容。

因此,请确保在系统上安装了正确的Ruby和兼容的Devkit。

有关详细信息,请参阅this tutorial

答案 1 :(得分:0)

有一组宝石依赖在一起。所以,我必须一步一步地安装。

正如我根据错误消息一个接一个地做的那样,我忘了记下这些步骤。