无法安装eventmachine ruby​​ gem。使用RVM,MacOS Lion

时间:2012-07-26 18:23:17

标签: ruby gem rvm eventmachine thin

我在MacOS Lion(内核v11.4.0)上使用RVM v1.10.2,ruby v1.9.3p0和ruby gems v1.8.15。

我使用sinatra为基于机架的项目创建了一个gemset,并安装了一堆宝石,包括eventmachine(由于安装了瘦身)。没问题。

几个星期后,我为一个类似的项目创建了一个新的gemset,但是当我尝试安装瘦身时,它都是失败的。看起来编译eventmachine有问题。我尝试创建一个新的gemset并自行安装eventmachine。没运气。我不知道它为什么会起作用,但现在却失败了。


每当我gem install eventmachine时,它都是这样的:

Fetching: eventmachine-0.12.10.gem (100%)
Building native extensions.  This could take a while...
ERROR:  Error installing eventmachine:
        ERROR: Failed to build gem native extension.

        /Users/jared/.rvm/rubies/ruby-1.9.3-p0/bin/ruby extconf.rb
checking for rb_trap_immediate in ruby.h,rubysig.h... no
checking for rb_thread_blocking_region()... yes
checking for inotify_init() in sys/inotify.h... no
checking for __NR_inotify_init in sys/syscall.h... no
checking for writev() in sys/uio.h... yes
checking for rb_thread_check_ints()... yes
checking for rb_time_new()... yes
checking for sys/event.h... yes
checking for sys/queue.h... yes
creating Makefile

make

然后它会在尝试编译各种文件时发出bajillion警告,最后,这个有趣的一点:

linking shared-object rubyeventmachine.bundle
ld: warning: ignoring file /usr/local/lib/libz.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64)
ld: in /usr/local/lib/libz.1.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [rubyeventmachine.bundle] Error 1

以下是完整输出:https://dl.dropbox.com/u/5382910/stackoverflow/gem_make.out


我没有安装其他宝石的问题,所以我怀疑这是一个编译器问题,但这是gcc -v的输出,万一有人可能会发现:

Using built-in specs.
Target: i686-apple-darwin11
Configured with: /private/var/tmp/llvmgcc42/llvmgcc42-2336.1~1/src/configure --disable-checking --enable-werror --prefix=/Developer/usr/llvm-gcc-4.2 --mandir=/share/man --enable-languages=c,objc,c++,obj-c++ --program-prefix=llvm- --program-transform-name=/^[cg][^.-]*$/s/$/-4.2/ --with-slibdir=/usr/lib --build=i686-apple-darwin11 --enable-llvm=/private/var/tmp/llvmgcc42/llvmgcc42-2336.1~1/dst-llvmCore/Developer/usr/local --program-prefix=i686-apple-darwin11- --host=x86_64-apple-darwin11 --target=i686-apple-darwin11 --with-gxx-include-dir=/usr/include/c++/4.2.1
Thread model: posix
gcc version 4.2.1 (Based on Apple Inc. build 5658) (LLVM build 2336.1.00)

非常感谢任何帮助!

2 个答案:

答案 0 :(得分:1)

你正在使用clang / LLVM来构建ruby - 这只是实验支持的,你需要使用不是基于LLVM的gcc-4.2,这在rvm要求中描述得非常好:

rvm get head     # get the latest update with the new requirements
rvm requirements # read carefully and follow instructions!

答案 1 :(得分:1)

这一行是关键:

ld: in /usr/local/lib/libz.1.dylib, file was built for unsupported file format which is not the architecture being linked (x86_64) for architecture x86_64

这是输出中唯一不仅仅是警告的东西。我不敢相信我忽略了它。这就是导致clang报告error: linker command failed的原因。我跑过后意识到这一点:Trouble Installing Ruby 1.9.2 with RVM Mac OS X

/usr/local/lib/libz.1.dylib只是/usr/local/lib/libz.1.2.5.dylib的符号链接,根据文件上的日期,它是在我第一次安装eventmachine之后的某个时间创建的。所以,我刚刚删除了/usr/local/lib/libz.1.dylib,我能够成功安装eventmachine。我甚至回到了LLVM gcc,它仍然有用。