• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1168
  • Last Modified:

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.
0
SBR210
Asked:
SBR210
  • 4
  • 2
2 Solutions
 
wesgarrisonCommented:
Use rvm:
http://rvm.beginrescueend.com/

You can install multiple ruby versions and they all stay nice and separate.  You don't have to mess with your system ruby, in case there is something that OS X uses it for.

You might also look into cinderalla:
http://www.atmos.org/cinderella/intro.html

It includes rvm along with everything else you need to get going on rails development (databases, gems, git, etc.)

I just used it on a fresh install and it was great, so I highly recommend it.
0
 
JESiiCommented:
Re: your PPS and default directories, the system automatically starts your terminal session in your "home" directory, something like
     /Users/JESii

You can change to a new directory with the 'cd' command (for change directory), such as
    cd /Users/JESii/Documents

If you really want to automatically do this when you start a Terminal session, then you'll have to learn a bit about bash, which is what's running in Terminal, and all the commands that are available there.

If you know how to edit a file in your home directory, then create a file called .bashrc [the leading dot is important], put one line in it that contains the cd command with the directory where you want to go, save the file, exit Terminal, and start Terminal again -- you should be automatically switched to that directory.

check out http://www.hypexr.org/bash_tutorial.php for more information about bash
0
 
SBR210Author Commented:
@ 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 http://rvm.beginrescueend.com/releases/rvm-install-head
#!/usr/bin/env bash

if [[ -f /etc/rvmrc ]] ; then source /etc/rvmrc ; fi
if [[ -f "$HOME/.rvmrc" ]] ; then source "$HOME/.rvmrc" ; fi
rvm_path="${rvm_path:-$HOME/.rvm}"
mkdir -p $rvm_path/src/
builtin cd $rvm_path/src
rm -rf ./rvm/
git clone git://github.com/wayneeseguin/rvm.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.

POST INSTALL
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=1.7.1.1
curl -O http://kernel.org/pub/software/scm/git/git-$version.tar.gz; tar xzf git-$version.tar.gz
cd git-$version && ./configure --prefix=/usr/local && make && sudo make install

# Install RVM
bash < <( curl http://rvm.beginrescueend.com/releases/rvm-install-head )

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


0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
SBR210Author Commented:
@JESii

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.
0
 
SBR210Author Commented:
@wesgarrison

By the way, I tried the procedure at http://rvm.beginrescueend.com/rubies/default/ 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
0
 
JESiiCommented:
Sure... there's a lot to learn, but you can get there.

Go here: http://programmingzen.com/ruby-and-rails-recommended-books/ 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.
0
 
SBR210Author Commented:
Thanks again to both of you - I was able to finally get Ruby installed using the Hivelogic instructions (http://hivelogic.com/articles/compiling-ruby-rubygems-and-rails-on-snow-leopard).  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.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now