为什么安装Ruby on Rails会产生错误"数组大小'ruby_check_sizeof_voidp'为负"?

Har*_*ton 19 ruby windows ruby-on-rails

安装Ruby on Rails(via gem install rails)时,您可能会收到以下错误消息:

c:/Ruby193/include/ruby-1.9.1/ruby/ruby.h:109:14: error: size of array 'ruby_check_sizeof_voidp' is negative
Run Code Online (Sandbox Code Playgroud)

还会有很多这样的警告:

c:/Ruby193/include/ruby-1.9.1/ruby/ruby.h:1333:12: warning: cast to pointer from integer of different size [-Wint-to-pointer-cast]
Run Code Online (Sandbox Code Playgroud)

还有一个错误

c:/Ruby193/include/ruby-1.9.1/ruby/missing.h:41:8: error: redefinition of 'struct timespec'
Run Code Online (Sandbox Code Playgroud)

为什么会发生这种情况?如何成功安装Rails?

Har*_*ton 30

当您为您的Ruby版本安装了错误版本的DevKit时会发生这种情况,例如,如果您安装DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe到Ruby版本1.9.3中.

要解决此问题,请重新安装Ruby并为您的Ruby版本安装正确的DevKit,如标题为"哪个开发工具包?"部分所示.在http://rubyinstaller.org/downloads.

  • 刚刚救了我一个小时的脑袋来对付这个问题 - 谢谢哈利! (4认同)
  • 如果您实际上已下载了正确版本的`DevKit`,但您之前安装了其他版本(只要您通过了[步骤4](https://github.com/oneclick/rubyinstaller/wiki/Development-Kit# 4-run-installation-scripts))你可能想尝试触发`<DEVKIT_INSTALL_DIR>\ruby​​ dk.rb init --force`(它不仅仅是`config.yml`在`init`步骤中准备好了). (4认同)
  • 位版本(32或64)也需要匹配;) (3认同)
  • 你可以通过这样做来检查你的Ruby版本:`$ irb`然后`['foo'].pack('p').size`.8位为64位,4位为32位.来源 - https://www.ruby-forum.com/topic/177435 (2认同)