Ruby 1.9.2 Install Errors with Mac OS X Lion and RVM

August 1st, 2011

I got my shiny new MBP on Friday and spent a good part of the weekend installing software. I ran into a installation issue with RVM and Ruby and just want to post a fix in case anyone runs across it. Just to be clear, the issue seems to be with Lion and not Ruby in general.

I successfully installed RVM (Ruby Version Manager) but received a nasty error when installing Ruby 1.9.2. My error log looked like:

[2011-07-30 16:52:07] ./configure –prefix=”/Users/Jeff/.rvm/usr”
checking for a BSD-compatible install… /usr/bin/install -c
checking whether build environment is sane… yes
checking for a thread-safe mkdir -p… config/install-sh -c -d
checking for gawk… no
checking for mawk… no
checking for nawk… no
checking for awk… awk
checking whether make sets $(MAKE)… no
checking for gcc… /usr/bin/gcc-4.2
checking whether the C compiler works… no
configure: error: in `/Users/Jeff/.rvm/src/yaml-0.1.4′:
configure: error: C compiler cannot create executables
See `config.log’ for more details

Essentially it means that “no acceptable compiler could be found.” There are a couple of problems with OS X Lion and Ruby. First, if you read the installation notes for RVM you’ll see the following:

For Lion, Rubies should be built using gcc rather than llvm-gcc. Since /usr/bin/gcc is now linked to /usr/bin/llvm-gcc-4.2, add the following to your shell’s start-up file: export CC=gcc-4.2

Lion sets the default compiler to LLVM so you’ll need to change it to gcc for Ruby to compile sucessfully. Open .bash_profile and add:

export CC=/usr/bin/gcc-4.2

The second problem seems to be with Xcode. Just becuase I “installed” Xcode 4.1 from the App Store doesn’t mean that it actually installed. To get Ruby to compile I had to launch Xcode and actually install Xcode. After that it compiled with no problem.

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Categories: Ruby

Leave a comment

Comments Feed9 Comments

  1. Mike Gill

    If that’s the only issue, that’s not too bad. Everything else ok on Mac?

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  2. Lance

    Just wanted to say thanks for writing this post. I’m a ruby noob with a new macbook and would have been even more lost if not for this guidance. Keep up the great work.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  3. Simon Bailey

    Thnx for this, I have just been recommended looking at this also to install gcc without Xcode https://github.com/kennethreitz/osx-gcc-installer (via @devboy_org).

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  4. Christian Höltje

    A better solution, since you’re using RVM, would be to add the line export CC=gcc-4.2 to your ~/.rvmrc file. That way it won’t alter compilation of other stuff, like homebrew.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  5. Iain B. Simpson

    Thanks very much Jeff.

    I’m a coding noob, experimenting with . Really enjoying learning about Ruby and GitHub.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  6. Braduck

    Thanks a lot! I was almost giving up when I found your tips. 100% ok, now!

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  7. Sid Kevein

    Cheers man, Just wanted to say thanks for writing this up.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  8. autoFilter

    Thank you.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)
  9. Steve

    I had this problem when installing samba on Lion:

    configure: error: C compiler cannot create executables

    For me the problem is because my xcode was 4.0.2 and it only works on Snow Leopard. Trying to run that xcode on Lion generated an error saying I need the newest xcode. Once I installed the latest xcode, 4.1.1, it got rid of the configure errors.

    Setting CC to point to a different cc didn’t work for me.

    VA:F [1.9.22_1171]
    Rating: 0.0/5 (0 votes cast)
    VA:F [1.9.22_1171]
    Rating: 0 (from 0 votes)

Leave a comment

Feed

http://blog.jeffdouglas.com / Ruby 1.9.2 Install Errors with Mac OS X Lion and RVM