56

I am trying to install Ruby 1.9.3 but am having problems. I installed RVM, then typed:

rvm install 1.9.3

The output says:

ERROR: Error running ' ./configure....

The log says:

configure: WARNING: unrecognized options: --with-libyaml-dir 
checking build system type... x86_64-apple-darwin11.2.0 
checking host system type... x86_64-apple-darwin11.2.0 
checking target system type...x86_64-apple-darwin11.2.0 
checking whether the C compiler works... no
configure: error: in `/Users/myuser/.rvm/src/ruby-1.9.3-p0':
configure: error: C compiler cannot create executables See `config.log' for more details

I downloaded the new XCode from the App Store and installed it.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
Klian
  • 1,520
  • 5
  • 21
  • 32
  • 1
    This may be relevant, user seems to have had the same problem as you: http://stackoverflow.com/questions/8032824/cant-install-ruby-under-lion-with-rvm-gcc-issues – siame Nov 15 '11 at 16:20

11 Answers11

118

Try using the clang compiler instead of the default:

rvm install 1.9.3 --with-gcc=clang
zzaman
  • 1,260
  • 1
  • 8
  • 6
15

RVM needs gcc-4.2 to be able to install ruby 1.9.3. Unfortunately Lion does not include anymore gcc-4-2, just the llvm version:

lrwxr-xr-x  1 root  wheel  12 15 feb 17:21 /usr/bin/gcc -> llvm-gcc-4.2

If you have Lion but upgraded from Snow Leopard it is likely that you still have gcc-4.2 If you have a brand new installation of Lion you should download gcc-4.2. I recommned downloading this package.

https://github.com/kennethreitz/osx-gcc-installer

Check that you have gcc-4.2 installed now:

-rwxr-xr-x  1 root  wheel  113024 16 may  2011 /usr/bin/gcc-4.2
lrwxr-xr-x  1 root  wheel      12 15 feb 17:21 /usr/bin/gcc -> llvm-gcc-4.2

Now you can install ruby 1.9.3 as usual:

rvm install 1.9.3
rvm use 1.9.3 --default
Marc M
  • 974
  • 10
  • 9
  • Thanks! I have a fresh install of Lion and the clang trick is no longer working - this got me going with 1.9.3. – Ian Feb 23 '12 at 02:59
  • @Marc M dude you rock I have been combing through threads looking for a reason why I was getting errors trying to upgrade Ruby on my work computer. The problem was that I was trying to install on a Mac Pro that was just upgraded to Lion from Leopard & I hadn't upgraded XCode yet. Fast solution when compared to a huge download! – Scott Sword Jun 26 '12 at 23:09
  • Also if you're on Mountain Lion, you can install the command-line tools (including GCC) from here: https://developer.apple.com/downloads/index.action?=Command%20Line%20Tools%20%28OS%20X%20Mountain%20Lion%29 – Jedidja Aug 19 '12 at 13:10
13

If you want to merely install and keep up to date the latest version of Ruby (as opposed to switching between different versions of ruby), you can install ruby via homebrew:

brew install ruby
Glorfindel
  • 21,988
  • 13
  • 81
  • 109
jupp0r
  • 4,502
  • 1
  • 27
  • 34
  • 3
    So far brew was the only way to get Ruby 1.9 installed on Mac OS Lion. All other advices described in this thread failed for me. I tried RVM 1.13.7 with all possible options and all of them failed on compilation phase. Only brew worked seamlessly – Vladimir Kroz May 22 '12 at 03:40
  • 1
    Since Rails will be dropping support of Ruby 1.8.7 anyway, so it's no use using RVM or Rbenv (not sure about the future though). 1.9.x is the preferred version, so this solution, with homebrew, is the best of the lot. – Sawant Dec 15 '12 at 15:14
  • Well, ruby is more than rails, there are still many frameworks not ported to 1.9 yet. There will also be new problems once 2.0 is out in february, so RVM is by no means obsolete. Still, homebrew is a good option for people who just want the latest stable. – jupp0r Dec 15 '12 at 19:13
6
  1. Open Xcode
  2. Open Xcode preferences
  3. Open Downloads tab
  4. Check Command Line Tools

Xcode screenshot

alex
  • 479,566
  • 201
  • 878
  • 984
sparkle
  • 7,530
  • 22
  • 69
  • 131
6

Try this first:

rvm get latest

This is what I have working:

  rvm:
    version:      "rvm 1.9.2 by Wayne E. Seguin (wayneeseguin@gmail.com) [https://rvm.beginrescueend.com/]"

  ruby:
    interpreter:  "ruby"
    version:      "1.9.3p0"
    date:         "2011-10-30"
    platform:     "x86_64-darwin11.2.0"
    patchlevel:   "2011-10-30 revision 33570"
    full_version: "ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]"
Sean Vikoren
  • 1,084
  • 1
  • 13
  • 24
6

Actually, ruby-1.9.3-p125 now works with gcc-llvm. But, the current stable/latest releases of rvm do not (yet). But that was just rvm being cautious and there's now a fix to that workaround in the master branch of rvm.

Simply, upgrade rvm to the master branch and install/upgrade ruby:

GT-MBP:~ gthiruva$ rvm upgrade ruby-1.9.3-p0 1.9.3
Are you sure you wish to upgrade from ruby-1.9.3-p0 to     ruby-1.9.3-p125? (Y/n): Y
Installing new ruby ruby-1.9.3-p125
Fetching yaml-0.1.4.tar.gz to /Users/gthiruva/.rvm/archives
Extracting yaml-0.1.4.tar.gz to /Users/gthiruva/.rvm/src
Configuring yaml in /Users/gthiruva/.rvm/src/yaml-0.1.4.
Compiling yaml in /Users/gthiruva/.rvm/src/yaml-0.1.4.
Installing yaml to /Users/gthiruva/.rvm/usr
The autodetected CC(/usr/bin/gcc-4.2) is LLVM based, it is not yet fully supported by
ruby and gems, please read `rvm requirements`, and set CC=/path/to/gcc .
Unable to install ruby ruby-1.9.3-p125.         Please install it manually to continue.
GT-MBP:~ gthiruva$ rvm get head
Original installed RVM version:

rvm 1.10.2 by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis
<mpapis@gmail.com>`enter code here` [https://rvm.beginrescueend.com/]
...
RVM reloaded!
GT-MBP:~ gthiruva$ rvm reload
RVM reloaded!
GT-MBP:~ gthiruva$ exec bash

rvm 1.10.2 by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> 
[https://rvm.beginrescueend.com/]

GT-MBP:~ gthiruva$ rvm upgrade ruby-1.9.3-p0 1.9.3
Are you sure you wish to upgrade from ruby-1.9.3-p0 to     ruby-1.9.3-p125? (Y/n): Y
Installing new ruby ruby-1.9.3-p125
...
Successfully migrated ruby-1.9.3-p0 to ruby-1.9.3-p125
Upgrade complete!
George
  • 271
  • 3
  • 6
3
  1. Uninstall/remove all traces of manually installed old ruby versions and extras (sqlite3, libxml2-x.x.x, libxslt-x.x.x) from your /usr/local/ or wherever you installed them.
  2. Download and install JewlryBox http://unfiniti.com/software/mac/jewelrybox which is a RVM GUI interface for managing your rubies and gemsets.
  3. In JewlryBox, click "Add Ruby" and choose the version of ruby you want to install (I chose 64 bit, Enabled Shared and didn't check/tick the "Use clang" option).

Worked with OS X Lion 10.7.3 and Xcode 4.3 Command Line Tools installed.

ALA
  • 39
  • 1
2

Type following commands

  • ~ $: source ~/.rvm/scripts/rvm
  • ~ $: type rvm | head -n 1

    rvm is a function

  • ~ $: vi ~/.bash_profile add this line into bash_profile "source ~/.rvm/scripts/rvm"

  • ~ $: rvm install 1.9.3

  • ~ $: rvm use 1.9.3
Tejasvi Manmatha
  • 564
  • 7
  • 12
0

Using rvm, ruby 1.9.3, and attempting to use gcc, I couldn't get Ruby to build cleanly with yaml. While there are a variety of hacks to get yaml compilation to work, none of them seemed to work with rvm. I was troubleshooting late at night and I didn't retain my errors, so I'm working from memory here -- I would appreciate if someone else with a clean environment could test these steps.

Using the --with-gcc=clang solution produced the mildly infamous error about the yaml parser:

It seems your ruby installation is missing psych (for YAML output). To eliminate this warning, please install libyaml and reinstall your ruby. 

Since I need yaml for what I'm going to be doing, and libyaml compiled fine when not being run by rvm, and I even had it installed in /usr/lib after building it by hand, I can't understand why rvm couldn't find and use that version of libyaml, even with the --shared-libs option.

Using CC=/usr/bin/gcc rvm install 1.9.3 produced errors. In the .rvm/log/ruby-1.9.3-p385/configure.log, I found the following:

configure: error: C compiler cannot create executables
See `config.log' for more details

That error was also present in .rvm/log/libyaml-0.14/configure.log.

The solution for me ended up being to run the rvm command with sudo. Running a compile as root seems to remove Apple's GCC toolchain's disapproval of users doing anything as dirty as compiling software.

So sudo CC=/usr/bin/gcc rvm install 1.9.3 --disable-binary gave me a clean compile of ruby+yaml in the rvm folder. I then needed to sudo chown -R username ~/.rvm && sudo chgrp -R staff ~/.rvm to get things back in my user and running with my permissions.

I do not recommend compiling things as root, as I see it as a security risk (especially with the vulnerabilities found in the ruby stack and rubygems.org recently) -- but this produced a clean installation of ruby under rvm and might help someone with more talent or time figure out the root cause of the issue with Apple's gcc.

Karl Katzke
  • 101
  • 2
0

Clang wasn't cutting any rubies for me and rvm install rubies failed no matter what with single user rvm. Sudo combined with some permission & $PATH changes to my user made it happen. Here's what I did:

sudo bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer )</pre>
sudo rvm pkg install readline
sudo rvm install 1.9.3

Installing rvm from root user makes a shell script at /usr/local/rvm/scripts/rvm Pulled code from this executable and placed it in my .bash_profile so that .bash_profile was saved as:

[ -s "/usr/local/rvm/scripts/rvm" ]] ;
    true ${rvm_path:="/usr/local/rvm"}
    source "/usr/local/rvm/scripts/rvm"
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function

The user group RVM was created during root user rvm install. Last thing I did was go to my preferences pane in OSX 10.7 and added my user to the new rvm group. Finally I reloaded my terminal and was able to install 1.9.3 through rvm single user.

Bent Cardan
  • 4,540
  • 2
  • 21
  • 17
-1

With the new Feb 2012 Command Line Tools for Xcode, using RVM 1.10.3 (and JweleryBox for Mac) Ruby 1.9.3-p125 compiles fine, without "Use clang" and with shared linking and 64 bit architecture. More over, the "gem install rails" command works flawlessly without the warning about libyaml support.

  • 1
    I wrote a simple guide on installing Ruby,Rails on Mac OS X Lion on my blog, take a look at http://sittisal.com/2012/03/01/the-easiest-and-best-way-to-install-ruby-and-rails-on-mac-os-x-lion/ – sittisal Mar 01 '12 at 09:46