Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I install Ruby 1.9.3 in Mac OS X Lion?

People also ask

What is Ruby on Mac OS X?

ruby-build is a plugin for rbenv that allows you to compile and install different versions of Ruby. ruby-build can also be used as a standalone program without rbenv. It is available for macOS, Linux, and other UNIX-like operating systems.


Try using the clang compiler instead of the default:

rvm install 1.9.3 --with-gcc=clang

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

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

Try this first:

rvm get latest

This is what I have working:

  rvm:
    version:      "rvm 1.9.2 by Wayne E. Seguin ([email protected]) [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]"

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 <[email protected]>, Michal Papis
<[email protected]>`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 <[email protected]>, Michal Papis <[email protected]> 
[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!