【问题标题】:can't install eventmachine ruby gem. using RVM, MacOS Lion无法安装 eventmachine ruby​​ gem。使用 RVM、MacOS Lion
【发布时间】:2012-07-26 18:23:16
【问题描述】:

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

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

几周后,我为一个类似的项目创建了一个新的 gemset,但是当我尝试安装 Thin 时,一切都失败了。看起来编译 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


我在安装其他 gem 时没有问题,所以我怀疑这是编译器问题,但这里是 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)

非常感谢任何帮助!

【问题讨论】:

    标签: ruby gem rvm eventmachine thin


    【解决方案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!
    

    【讨论】:

    • 谢谢。我使用 Homebrew 安装了 apple-gcc42,但仍然出现同样的错误。 gcc 现在是 4.2.1 版(Apple Inc. build 5666)。如何阻止它使用 clang?
    • 你当前的 rvm 版本是什么,这很重要,因为旧版本对 gcc 的处理方式不同
    • 我使用的是 v1.10.2,但根据您的建议,我进行了更新,现在正在运行 v1.14.7。两个版本下同样的问题。
    • 您可能需要rvm reload 甚至重新登录才能重新加载 - 旧版本不会自动重新加载。
    • 感谢您的帮助。原来这个错误与 LLVM 无关。请参阅下面的答案。
    【解决方案2】:

    这一行是关键:

    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,它仍然有效。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-12-12
      • 1970-01-01
      • 2013-03-21
      • 2011-12-23
      • 2013-01-17
      • 1970-01-01
      • 1970-01-01
      • 2011-10-11
      相关资源
      最近更新 更多