tags:

views:

83

answers:

4

I am reading the book Programming Ruby and am looking to upgrade the version of Ruby on my computer. I run Mac OS X Snow Leopard and doing ruby -v in the command line shows I am running Ruby 1.8.7.

I installed MacPorts and ran the sudo port install ruby19 command but whenever I type ruby -v, it still shows Ruby 1.8.7.

Could anyone help with this? Thank you.

+2  A: 

You have to use ruby19 to run ruby if you installed it that way. You can also use irb19, and ri19.

jtbandes
Thank you for the help! I went into /opt/local/bin and figured out that it's ruby1.9
Victor
+7  A: 

The tool "rvm" is pretty good. It stands for Ruby Verson Manager I think, and the developer is good at support in the irc channels. You can install multiple versions of ruby along side each other pick the ones you want to use.

http://rvm.beginrescueend.com/

hvgotcodes
rvm is the best way to deal with multiple versions of ruby. if you have mac ports you should have the devtools, so install rvm, then rvm install 1.9 and rvm use 1.9 --default and you should be good to go. it will handle all the pathing and gems and the like, keeping them sandboxed away from the system version.
Doon
I use and recommend rvm also. I have 1.8.7-head and the current 1.9.1 installed, along with the usual system version of Ruby, making it easy to run and/or test code with any version.
Greg
Thank you! I will definitely check rvm out.
Victor
A: 

As @Andrew Grimm eluded, the problem you are having is likely due to a problem in your $PATH variable. Since macports typically installs stuff in /opt, modifying your $PATH variable to:

$ export PATH=/opt/local/bin:$PATH

Will most likely help. However, I would urge you to look into RVM as @hvgotcodes recommends.

Brian
A: 

As mentioned in hvgotcodes answer, RVM seems to be a great way of handling this.

I recently started learning Ruby (and Rails) myself, and this[1] tutorial has a great section on using RVM. I'd highly recommend you give it a go, it's especially handy so that you can follow different tutorials on different versions of Ruby if you wish.

[1] http://railstutorial.org/book#sec:rubygems

Rob Gough