Link to home
Start Free TrialLog in
Avatar of SBR210
SBR210Flag for United States of America

asked on

How to replace Ruby 1.8.7 with Ruby 1.9.2 on Mac OS 10.6.4?

I have a Mac OS X with Snow Leopard 10.6.4 that has Ruby 1.8.7 preinstalled from the factory.  I have zero experience with Terminal and programming, but I am trying to learn Ruby and want to upgrade to the latest version 1.9.2.  I have tried various methods in books, on the web, Locomotive, etc. and I just cannot figure out how to get it installed and configured as the default.  The resources on the web for this keep losing me at various technical details.  Can anyone provide detailed, step-by-step instructions for how to do this for an absolute beginner?  I would like to have all the ancillary programs like Rails, RadRails, gems, etc. as well.  Thanks very much for any assistance.

P.S. On the current version, I also cannot get Shebang, the Tk toolkit (which is factory installed), or the "sprintf" command to work.

P.P.S.  How can I change the default directory that Terminal looks for programs in?  Right now it's under my user root directory but I don't know how to change to another default folder I'd rather use.
Avatar of wesgarrison
Flag of United States of America image

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SBR210


@ wesgarrison
Thanks very much for the advice.  I decided to try RVM since the Cinderella seems to default install an older version of Ruby, and I'm not sure of the method to designate the latest version...

So I followed the instructions and downloaded RVM via Curl, and this was the result I got (my command in the first line):

iMac:~ sbriffe$ curl
#!/usr/bin/env bash

if [[ -f /etc/rvmrc ]] ; then source /etc/rvmrc ; fi
if [[ -f "$HOME/.rvmrc" ]] ; then source "$HOME/.rvmrc" ; fi
mkdir -p $rvm_path/src/
builtin cd $rvm_path/src
rm -rf ./rvm/
git clone git://
builtin cd rvm
bash ./scripts/install

So from this, I assume the installation was successful?  How can I check this?  Also, I have been studying the post-installation instructions (reproduced below) and I don't understand how to do any of it.  I'm really a complete novice with this stuff, sorry if these are dumb questions.  How can I confirm that Ruby 1.9.2 has been installed correctly, and if not, how do I complete the installation?  How do I set the default Ruby as 1.9.2 rather than the factory's 1.8.7?  Thanks again for the help, it's very much appreciated.

P.S. What is the three-dot symbol in these instructions below represent?  I tried entering several of the commands in the instructions below at my Bash prompt in Terminal and it resulted in errors.

The first time you install RVM, you must put the following line into your profile at the very end, after all path loads etc:
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"  # This loads RVM into a shell session.

Doing so ensures rvm is loaded as a function (versus as a binary), ensuring commands such as rvm use work as expected. Please note that you can confirm this worked correctly by opening a new shell and running:
¿ type rvm | head -n1

If this was performed correctly, you should see:
rvm is a function

Next, you can manually load the new code into your current shell and start using RVM ! w00t!
¿ source ~/.rvm/scripts/rvm

Be sure to install any dependencies for your operating system by running:
¿ rvm notes

The following script will boostrap git + RVM assuming that you have curl & sudo installed. It will also install (last line) several common rubies.
#!/usr/bin/env bash

# Install git
mkdir -p $HOME/.rvm/src && cd $HOME/.rvm/src && version=
curl -O$version.tar.gz; tar xzf git-$version.tar.gz
cd git-$version && ./configure --prefix=/usr/local && make && sudo make install

# Install RVM
bash < <( curl )

# Install some rubies
source "$HOME/.rvm/scripts/rvm"
rvm install ree,1.9.2-head,jruby

Avatar of SBR210



Thanks very much for the help, the Bash tutorial looks really helpful, although it's still too advance for me to make a lot of use of it.  I've started studying Ruby and HTML but I think I'm missing a lot of foundational knowledge.  Are there any books or resources that you've found helpful that could get me up to speed on this stuff?  I've programmed a little in Basic before and recently read some beginning programming type books, but they haven't covered this gap in knowledge and I seem to be out of my depth from the beginning here.  Thanks again.
Avatar of SBR210



By the way, I tried the procedure at which is also listed below for switching the default Ruby to the newest version:

"Setting the default Ruby

If you would like to make one specific Ruby be the default ruby that is selected when you open a new terminal shell simply use the --default flag:

¿ rvm --default ruby-head

¿ ruby -v  #=> ruby 1.9.2dev (2010-02-25 trunk 26759) [x86_64-darwin10.2.0]"

but I got the following result instead:

-bash: rvm: command not found
Sure... there's a lot to learn, but you can get there.

Go here: for a good list of books, from Absolute Beginner to advanced.

I like the O'Reilly book "The Ruby Programming Language" andThe Ruby Way (2nd Edition) by Obi Fernandez. There's also "The Well-Grounded Rubyist" by Apress which I like.
Avatar of SBR210


Thanks again to both of you - I was able to finally get Ruby installed using the Hivelogic instructions (  I am still getting a configuration error trying to run the .config command to install MySql but that will be the topic of a different post if I can't fix it.