ruby-on-rails - gem install json 失败,重新定义了 struct timezone/timespec

标签 ruby-on-rails ruby json compiler-errors gem

我在 Windows 上使用带有 DevKit 的 Ruby 1.9.3(在 Win 7 64 位上都是 32 位)。现在我尝试安装 rails,但从 bundle 中得到一个错误。如果我尝试运行(包在提示什么)

 gem install json

我收到以下错误消息:

D:\RubyTest>gem install json
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.

        D:/Ruby193/bin/ruby.exe extconf.rb
creating Makefile

make
generating generator-i386-mingw32.def
compiling generator.c
In file included from d:/Ruby193/include/ruby-1.9.1/ruby/ruby.h:1381:0,
                 from d:/Ruby193/include/ruby-1.9.1/ruby.h:32,
                 from ../fbuffer/fbuffer.h:5,
                 from generator.c:1:
d:/Ruby193/include/ruby-1.9.1/ruby/missing.h:41:8: error: redefinition of 'struc
t timespec'
In file included from d:\ruby193\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/../
../../../i686-w64-mingw32/include/process.h:12:0,
                 from d:/Ruby193/include/ruby-1.9.1/ruby/win32.h:62,
                 from d:/Ruby193/include/ruby-1.9.1/ruby/defines.h:223,
                 from d:/Ruby193/include/ruby-1.9.1/ruby/ruby.h:67,
                 from d:/Ruby193/include/ruby-1.9.1/ruby.h:32,
                 from ../fbuffer/fbuffer.h:5,
                 from generator.c:1:
d:\ruby193\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-ming
w32/include/sys/types.h:89:8: note: originally defined here
In file included from d:/Ruby193/include/ruby-1.9.1/ruby/ruby.h:1381:0,
                 from d:/Ruby193/include/ruby-1.9.1/ruby.h:32,
                 from ../fbuffer/fbuffer.h:5,
                 from generator.c:1:
d:/Ruby193/include/ruby-1.9.1/ruby/missing.h:48:8: error: redefinition of 'struc
t timezone'
In file included from d:/Ruby193/include/ruby-1.9.1/ruby/win32.h:63:0,
                 from d:/Ruby193/include/ruby-1.9.1/ruby/defines.h:223,
                 from d:/Ruby193/include/ruby-1.9.1/ruby/ruby.h:67,
                 from d:/Ruby193/include/ruby-1.9.1/ruby.h:32,
                 from ../fbuffer/fbuffer.h:5,
                 from generator.c:1:
d:\ruby193\mingw\bin\../lib/gcc/i686-w64-mingw32/4.7.2/../../../../i686-w64-ming
w32/include/time.h:260:8: note: originally defined here
make: *** [generator.o] Error 1


Gem files will remain installed in D:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.7.
7 for inspection.
Results logged to D:/Ruby193/lib/ruby/gems/1.9.1/gems/json-1.7.7/ext/json/ext/ge
nerator/gem_make.out

有什么想法吗?

最佳答案

Ruby 1.9.3 是使用 GCC 4.5.2 编译的,它是 DevKit DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe 可从 RubyInstaller's download page 获得

如 RubyInstaller 公告中所述,您下载了较新的 DevKit,它们与 Ruby 2.0.0 版本兼容。

澄清一下:

  • ruby 1.8.7:tdm-32-4.5.2
  • ruby 1.9.2:tdm-32-4.5.2
  • ruby 1.9.3:tdm-32-4.5.2
  • Ruby 2.0.0:mingw64-32-4.7.2(以及 64 位 Ruby 的 64 位版本)

我已在 RubyInstaller 下载页面中添加了关于此的说明。

希望对你有帮助

关于ruby-on-rails - gem install json 失败,重新定义了 struct timezone/timespec,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15121247/

相关文章:

ruby-on-rails - Jammit::MissingConfiguration - precache_all':需要 --base-url 选项才能生成 MHTML

arrays - 计算 x 和 y 之间的值在数组中出现的次数

ruby-on-rails - 我可以在 gem 中仅从文件中获取一次数据吗?类似于 Rails 中的配置/初始化器?

ruby-on-rails - 用于模型或仅 Controller 的 Ruby on Rails 命名空间

javascript - Split 不适用于 JavaScript 中的 json_encode

ruby-on-rails - Rails 中的锁/事务/隔离级别的详尽指南

ruby-on-rails - Rails Formbuilder 问题

ruby-on-rails - Rails 3.2 Assets 主机设置被忽略

java - BodyEditorLoader 中的 float 和 Dictionary 错误,如何修复?

javascript - 仅当相同的 div 不存在时才生成并附加数据