vom 27.07.2012 um 13:49 Uhr von Frank
Kategorie(n): Ruby

Install Ruby 1.9.3 on OS X 10.8 Mountain Lion

OS X 10.8 ships with a very old version of Ruby (1.8.7). This tutorial describes the straight forward installation of pure Ruby 1.9.3 via compilation of sources on OS X Mountain Lion 10.8 in the terminal. Tools like RVM are not used.

You need some basic knowledge of working with a *NIX terminal.

My environment for this tutorial

A clean installation of OS X 10.8 in a VMWare Fusion (Version 4.1.3) Container on an OS X 10.7.4 host. If you use a dedicated machine the following procedure should work too.

OS X Requirements

  • working internet connection
  • installed Xcode from Mac App Store
  • installed Command Line Tools for Xcode (run Xcode, then Preferences > Downloads)

Prerequisites

Install Homebrew

Homebrew is a useful package manager to add missing administrative packages to OS X. The library libyaml is needed by psych (Ruby Standard Library) during compilation:


 /usr/bin/ruby -e “$(/usr/bin/curl -fsSL https://raw.github.com/mxcl/homebrew/master/Library/Contributions/install_homebrew.rb)”
 brew doctor
 brew install wget libyaml

 

Download and uncompress Ruby sources

For software which I install beside the standard package management of the specific OS I’m using the /usr/local directory. Sources go into /usr/local/src and binaries in /usr/local/*bin. On a default OS X installation these directories doesn’t exist so we have to create them:


 mkdir -p /usr/local/src
 chgrp admin /usr/local/src
 chmod -R 775 /usr/local/src
 cd /usr/local/src
 wget ftp://ftp.ruby-lang.org/pub/ruby/1.9/ruby-1.9.3-p194.tar.bz2
 tar xzvf ruby-1.9.3-p194.tar.bz2

 

Install Ruby:


 cd ruby-1.9.3-p194
 sudo ./configure —enable-shared —enable-pthread CFLAGS=-D_XOPEN_SOURCE=1
 sudo make && sudo make install

 

At this time we have two Ruby binaries installed, the ancient default OS X package in /usr/bin and the new one in /usr/local/bin. To use the actual version we have to instruct OS X to look for the new ruby in /usr/local/bin. If you have modified your PATH variable in this sense before (for other software), you can skip this step:


 echo “export PATH=\”/usr/local/bin:\$PATH\”“ > ~/.profile
 . ~/.profile # reload .profile with new $PATH var

 

Verify your installation:


 which ruby # => /usr/local/bin/ruby
 ruby -v # => ruby 1.9.3p194 (2012-04-20 revision 35410) [x86_64-darwin12.0.0]

 

Update rubygems & installed default gems:


 sudo gem update —system && sudo gem update
 gem -v # => 1.8.24 (can differ on your system due to meanwhile updates)

 

 

...hier geht's zum Formular ↓

1

> Geschrieben von Daniel Kehoe am 31.07.2012 um 23:38

Thanks for showing how to install Ruby 1.9.3 without rvm on OS X 10.8. I wonder why Apple doesn't ship the OS with the current Ruby 1.9.3. BTW, here's my guide for Installing Rails which gives all the details of upgrading bundler, etc. for a healthy development environment.

 

2

> Geschrieben von Joachim Haagen Skeie am 15.08.2012 um 10:11

Thank you for this guide! Saved me hours of work figuring this out!!

 

3

> Geschrieben von Stephan am 16.08.2012 um 11:42

Why not use RVM (https://rvm.io) or rbenv (https://github.com/sstephenson/rbenv/), if you prefer that.

 

Die mit * markierten Felder sind Pflichtfelder. Deine E-Mail Adresse wird im Beitrag nicht angezeigt.

Commenting is not available in this weblog entry.