2

我刚刚用 Xcode 4.1 安装了 OS X Lion。我正在使用 Ruby 1.9.2 和 gems 版本 1.5.0。尝试从 Rails 3.0.9 升级到 3.1 时,出现以下错误:

$ ruby -v
ruby 1.9.2p0 (2010-08-18 revision 29036) [i386-darwin9.8.0]
$  rails -v
Rails 3.0.9
$  gem -v
1.5.0
$  gem update rails
Updating installed gems
Updating rails
Building native extensions.  This could take a while...
ERROR:  Error installing rails:
    ERROR: Failed to build gem native extension.

        /Users/me/.rvm/rubies/ruby-1.9.2-p0/bin/ruby extconf.rb
creating Makefile

make
gcc -I. -I/Users/me/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/i386-darwin9.8.0 -I/Users/me/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/backward -I/Users/me/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1 -I. -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE   -fno-common -O3 -ggdb -Wextra -Wno-unused-parameter -Wno-parentheses -Wpointer-arith -Wwrite-strings -Wno-missing-field-initializers -Wshorten-64-to-32 -Wno-long-long  -fno-common -pipe  -o bcrypt_ext.o -c bcrypt_ext.c
In file included from /Users/me/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby.h:32,
                 from bcrypt_ext.c:1:
/Users/me/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/ruby.h:108: error: size of array ‘ruby_check_sizeof_long’ is negative
/Users/me/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/ruby.h:112: error: size of array ‘ruby_check_sizeof_voidp’ is negative
In file included from /Users/me/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/intern.h:29,
                 from /Users/me/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/ruby.h:1327,
                 from /Users/me/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby.h:32,
                 from bcrypt_ext.c:1:
/Users/me/.rvm/rubies/ruby-1.9.2-p0/include/ruby-1.9.1/ruby/st.h:69: error: size of array ‘st_check_for_sizeof_st_index_t’ is negative
bcrypt_ext.c: In function ‘bc_salt’:
bcrypt_ext.c:42: warning: implicit conversion shortens 64-bit value into a 32-bit value
make: *** [bcrypt_ext.o] Error 1


Gem files will remain installed in /Users/me/.rvm/gems/ruby-1.9.2-p0/gems/bcrypt-ruby-3.0.1 for inspection.
Results logged to /Users/me/.rvm/gems/ruby-1.9.2-p0/gems/bcrypt-ruby-3.0.1/ext/mri/gem_make.out
Nothing to update

有谁知道这里发生了什么?

谢谢!

4

1 回答 1

1

而不是做“更新”,只做“gem install rails -v 3.1”

更新: 显然rails 3.1.0(实际上是activemodel)取决于bcrypt-ruby。应该在 3.1.1 中删除此依赖项(请参阅https://github.com/rails/rails/issues/2687)。

如果您不想等待,则需要解决 bcrypt-ruby 的构建问题。编译器错误表明 ruby​​ 和编译器之间存在 32 位/64 位不匹配。您是否在 Leopard 上安装了 Lion?如果是这样,您可能必须重建所有 rvm rubies 和本机扩展 gem。

即使您想等待,您也可能应该重新构建,因为您可能会再次遇到此类编译器问题。作为测试,尝试安装一个原生 gem,例如:“gem install eventmachine”。如果您遇到相同的错误,则表明每个本地 gem 都会遇到此问题。

有关升级到 Snow Leopard 时遇到类似问题的人,请参阅此页面,并解释问题:http: //jtigger-learning.wikidot.com/gem-install-fails-on-building-native-extensions

于 2011-09-14T16:22:14.790 回答