Search code examples
rubyrubygemsrvmeventmachinethin

can't install eventmachine ruby gem. using RVM, MacOS Lion


I'm using RVM v1.10.2, ruby v1.9.3p0, and ruby gems v1.8.15 on MacOS Lion (kernel v11.4.0).

I created a gemset for a rack-based project using sinatra and installed a bunch of gems, including eventmachine (as a result of installing thin). No problems.

A few weeks later I created a new gemset for a similar project, but it was all fail-zoar when I tried to install thin. Looks like there's a problem with compiling eventmachine. I tried creating a fresh gemset and installing eventmachine by itself. No luck. I don't know why it worked once, but now fails.


Whenever I gem install eventmachine, it goes like this:

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

then it issues a bajillion warnings as it tries to compile various files, then, finally, this interesting bit:

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

Here's the complete output: https://dl.dropbox.com/u/5382910/stackoverflow/gem_make.out


I don't have problems installing other gems, so I'm doubting it's a compiler issue, but here's the output of gcc -v, in case anyone might spot something:

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)

Any help is much appreciated!


Solution

  • This line is the key:

    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
    

    It's the only thing in the output that wasn't just a warning. I can't believe I overlooked it. That's what caused clang to report error: linker command failed. I realized this after running across: Trouble Installing Ruby 1.9.2 with RVM Mac OS X.

    /usr/local/lib/libz.1.dylib is just a symlink to /usr/local/lib/libz.1.2.5.dylib, and according to the date on the file, it was created sometime after I installed eventmachine that first time. So, I just deleted /usr/local/lib/libz.1.dylib and I was able to install eventmachine successfully. I even reverted back to the LLVM gcc and it still worked.