15

I'm getting an error after compiling Ruby 1.8.7 using RVM on Lion 10.7.1 with Xcode 4.2 GM (new MacBook).

It compiles fine but when I try to install any gem I get the following:

gem install bundler
/Users/me/.rvm/rubies/ruby-1.8.7-p352/lib/ruby/1.8/timeout.rb:60: [BUG] Bus Error
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-darwin11.1.0]

Abort trap: 6

Update: In the end I hope to have Xcode 4.2 installed, RVM with Ruby 1.8.7, 1.9.x installed and all working properly.

1
  • 1
    This seems related - try the fix he used? Looks like a deepseated incompatibility of some sort.
    – millimoose
    Commented Oct 12, 2011 at 1:40

7 Answers 7

24

Since I had to parse through several of these answers to get things working with XCode 4.2, I thought I'd put it all together:

  1. Install Xcode 4.2
  2. Install the gcc standalone compiler from https://github.com/kennethreitz/osx-gcc-installer (which replaces Xcode)
  3. Add export CC=gcc-4.2 to your ~/.bash_profile or equivalent (don't forget to reload it)
  4. Run rvm implode" then re-install rvm http://beginrescueend.com/

At this point I was able to rvm install ruby-1.8.7 (and ruby-1.9.2), and actually get my gems to install.

4
  • Do you still have Xcode 4.2 installed? Where does that fit into the install steps?
    – Nate Bird
    Commented Oct 20, 2011 at 14:56
  • it worked for me with Lion system (fresh installed) with Xcode 4.2.1. However, can someone explain why this is the problem? Thanks!
    – imcc
    Commented Nov 20, 2011 at 17:46
  • Do you mean it works without using the workaround with Xcode 4.2.1? That would be good to know. The issue happened because Apple changed the default compiler to the pure LLVM compiler in Xcode 4.2, and it looks like Ruby doesn't compile properly with it. The default compiler section here has a bit more info: Apple Xcode 4.2 docs.
    – Alex Dixon
    Commented Nov 22, 2011 at 4:32
  • Here is an explanation of why Xcode 4.2 doesn't work from Apple's release notes: The default compiler for iOS development in Xcode 4.2 is LLVM 3.0. Compared with the GCC compiler that was the default in Xcode 4.0 and the LLVM-GCC compiler in Xcode 4.1, LLVM provides better code generation and optimization than GCC, along with newer language support than LLVM-GCC, including support for ARC in Objective-C and for the new C++ standard, C++0x Essentially the new compiler in Xcode 4.2 doesn't have the same GCC compiler as previous versions and Ruby 1.9.2+ chokes using the LLVM only compiler.
    – Nate Bird
    Commented Dec 30, 2011 at 13:39
3

So nuking RVM (rvm implode) and reinstalling didn't make any difference. I ended up installing Xcode 4.2 and then installing the GCC compilers after which overrides the Xcode compilers.

Here are the steps for those Googling this.

  1. Install Xcode 4.2.x

  2. Install GCC standalone compilers from https://github.com/kennethreitz/osx-gcc-installer

    Note: Xcode 4.3 beta was recently released. I'm testing if this fixes the compilation issues.

1
  • I have Xcode 4.3 and still had this problem. Fixed by installing the osx-gcc-installer mentioned here and the CC=/usr/bin/gcc-4.2 rvm reinstall 1.8.7-p352
    – Norto23
    Commented May 31, 2012 at 4:36
2

Multiple articles suggest that Ruby doesn't like being compiled with LLVM being involved. The stopgap measure is to thoroughly remove the RVM install – the linked articles say how – and then recompile Ruby with plain GCC. The real fix will have to come from Apple/LLVM or the Ruby team.

2

I fix that by

  1. installing Xcode 4.2.x,
  2. adding export CC=gcc into ~/.bash_profile,
  3. Reloading environment (source ~/.bash_profile),
  4. executing rvm install 1.9.3,
  5. executing rvm ruby-1.9.3-rc1,
  6. executing gem update --system and finally
  7. executing gem install bundler

The problem is with Xcode 4.2.x version. If you run rvm get head you will see this message "DO NOT use Xcode Version 4.2.x. It currently fails to build several rubies and gems...".

I don't have solution for ruby v1.8.7.

I hope it helps.

1
  • 1
    Yeah. I was able to get 1.9.2 to compile fine. 1.9.3 needs the export CC=gcc in ~/.bash_profile or ~/.rvmrc. I was never able to get 1.8.7 to compile until I imploded RVM, uninstalled Xcode and installed the GCC standalone compilers. See my solution above.
    – Nate Bird
    Commented Oct 17, 2011 at 16:05
1

You can download find stand alone GCC installer instructions here: https://github.com/kennethreitz/osx-gcc-installer

This gives you a non llvm based gcc installation without having to mess around with Xcode.

You can then use the command

 export CC=/usr/bin/gcc-4.2 

This allows you to have the latest X Code for OSX purposes and still have a happy gcc version for ruby.

1

I need to use Xcode on this machine, so the standalone gcc wasn't quite going to do it for me.

Per other posters, I followed the suggestions at the end of the RVM update's release notes.

Note, I didn't need to remove RVM. I was successful with a removal of Xcode 4.2.1 (completely), and a reinstall of Xcode 4.1, then doing the CC=/usr/bin/gcc-4.2 rvm install 1.8.7 trick. In my case I put export CC="/usr/bin/gcc-4.2" in my profile to save some typing while also setting up various gems.

This also worked for Ruby Enterprise Edition (ree-1.8.7-2011.03) which had been failing as well.

0

The rvm post-install documentation says:

** Lion Users: DO NOT use Xcode Version 4.2.x for OS X Lion. It currently fails to build several rubies and gems, as well as several Homebrew and Macports packages as well. Xcode Version 4.1 (4B110) works. You can find Xcode 4.1 for OS X Lion at: https://developer.apple.com/downloads/download.action?path=Developer_Tools/xcode_4.1_for_lion/xcode_4.1_for_lion.dmg

This worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.