Solved

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

Posted on 2010-09-04
7
1,154 Views
Last Modified: 2012-06-27
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
Comment
Question by:SBR210
  • 4
  • 2
7 Comments
 
LVL 14

Accepted Solution

by:
wesgarrison earned 250 total points
ID: 33605135
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
 
LVL 12

Assisted Solution

by:JESii
JESii earned 250 total points
ID: 33606554
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
 

Author Comment

by:SBR210
ID: 33642251
@ 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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

Author Comment

by:SBR210
ID: 33642274
@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
 

Author Comment

by:SBR210
ID: 33642443
@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
 
LVL 12

Expert Comment

by:JESii
ID: 33642452
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
 

Author Comment

by:SBR210
ID: 33645144
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

The error "There was an error performing the update" occurred on a Mac OS X client workstation running  Symantec AntiVirus for Mac (http://www.symantec.com/business/products/purchasing.jsp?pcid=pcat_security&pvid=825_1) - the Enterprise product vers…
In this article we will discuss some EI Capitan Mail app issues and provide some manual process to resolve them.
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now