9

I am following the Ruby on Rails tutorial and I'm hung up on installing Ruby 1.9.2. It has been stuck at the #compiling function for ~36 hours. I tried to find my configure.log file but I honestly haven't been able to.

What I have done so far: 1) Installed XCode 2) Installed GCC 10.7v2

The command I used:

RVM reloaded!
vinnies-macbook:~ vinnie$ rvm install 1.9.2 --with-gcc=clang
Fetching yaml-0.1.4.tar.gz to /Users/vinnie/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/vinnie/.rvm/src
Configuring yaml in /Users/vinnie/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/vinnie/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/vinnie/.rvm/usr
clang: error: unsupported option '--with-libyaml'
Building 'ruby-1.9.2-p318' using clang - but it's not (fully) supported, expect errors.
Installing Ruby from source to: /Users/vinnie/.rvm/rubies/ruby-1.9.2-p318, this may take a          while depending on your cpu(s)...

ruby-1.9.2-p318 - #fetching 
ruby-1.9.2-p318 - #extracted to /Users/vinnie/.rvm/src/ruby-1.9.2-p318 (already extracted)
ruby-1.9.2-p318 - #configuring 
ruby-1.9.2-p318 - #compiling 
Vincent Barr
  • 91
  • 1
  • 5

3 Answers3

17

For Lion, you need to install GCC-4.2 and set the compile to point to it:

  1. Download the gcc-4.2

    This is needed for Xcode 4.2 only. Ruby project should be built using gcc rather than llvm-gcc (Lion).

    Download it from https://github.com/kennethreitz/osx-gcc-installer/downloads/

    Open "Downloads"

    Double click on "GCC-10.7-v2.pkg" to install

  2. Setting the compiler

    For Lion, Rubies should be built using gcc rather than llvm-gcc.

    Since /usr/bin/gcc is linked to /usr/bin/llvm-gcc-4.2, we need to set the default complier to gcc-4.2

    Set default complier to gcc-4.2, type command: export CC=/usr/bin/gcc-4.2

yeowzir
  • 309
  • 1
  • 5
  • Just a note that Ruby 1.9.3-p125 (and I expect onward from there in the future) can be built correctly with clang. – Andrew Marshall Mar 05 '12 at 04:55
  • @AndrewMarshall 1.9.3-p125+ most of the times builds, but sometimes it splits out a nasty bug when compiling miniruby. – mpapis Mar 05 '12 at 06:03
  • Yeowzir, thank you. I pointed the compiler to Gcc-4.2 following your instruction. It appears to be compiling without error. Do you have a rough idea of how long it will take to compile on a MacBook air? I want to make sure that compiling is happening, not just some sort of delay-ing. **Edit** It worked! – Vincent Barr Mar 05 '12 at 20:58
0

Either you are running older RVM or gcc-4.2 could not be found.

Are you sure https://github.com/kennethreitz/osx-gcc-installer/downloads/ was correctly installed?

RVM automatically detects that gcc-4.2 is available and uses it for compilation, so you should be fine after:

rvm get head
rvm reinstall 1.9.2 -j 2

I have added -j 2 to speed up compilation, replace the 2 with number of cores +1

mpapis
  • 52,729
  • 14
  • 121
  • 158
-2

There are better ways now. You can use MacPort to download and compile everything.

  1. Install MacPort http://www.macports.org/
  2. From a terminal window, install Ruby

    sudo port selfupdate
    sudo port install ruby 1.9.2
    

Better yet, you can use RVM to install a specific version of ruby depending on where you are:

  1. Install MacPort
  2. Install RVM https://rvm.io
  3. cd [my work dir]
  4. rvm 1.9.2
Bernard
  • 16,149
  • 12
  • 63
  • 66
  • 5
    I'd disagree that MacPorts is a better solution. Further, the user *is* using RVM. – Andrew Marshall Mar 05 '12 at 04:55
  • MacPort may have issues with complex and obscure packages but I've certainly never had any problem with it for installing Ruby. – Bernard Mar 05 '12 at 04:59
  • I think the problem with MacPorts is that its overzealous about installing dependencies that come with the OS. I personally find [Homebrew](http://mxcl.github.com/homebrew/) far superior. – Andrew Marshall Mar 05 '12 at 05:01
  • Yes, many people report that they prefer Homebrew for that reason. However as I said, MacPort is perfectly fine for installing Ruby and it is used by a lot more people than Homebrew. – Bernard Mar 05 '12 at 06:06
  • Perhaps that's just because it has been around far longer? `;)` Homebrew, is, though, the most-forked repo on Github. – Andrew Marshall Mar 05 '12 at 06:08