tags:

views:

743

answers:

8

Hi,

Can anyone please give directions on how to install ruby 1.9 I tried installation directions given all over the web. Can't get it to work. Please kindly give step by step direction. I tried using macports but everytime I type in ruby -v it gives me 1.8.6.

Thanks

Ken

A: 
  1. Install MacPorts
  2. Type port install ruby19
Chip Uni
I get the following error:kapplej-4:~ Home$ port install ruby19Warning: MacPorts running without privileges. You may be unable to complete certain actions (e.g. install).---> Computing dependencies for ruby19---> Dependencies to be installed: libiconv gperf ncurses ncursesw openssl zlib readline---> Installing gperf @3.0.4_0Error: Target org.macports.install returned: MacPorts requires root privileges for this actionError: The following dependencies failed to build: libiconv gperf ncurses ncursesw openssl zlib readline
Ken
Error: Status 1 encountered during processing.To report a bug, see <http://guide.macports.org/#project.tickets>kapplej-4:~ Home$ ruby-v-bash: ruby-v: command not found
Ken
+2  A: 

Ok this is how I remember doing it

  1. Install Macports
  2. Type sudo port install ruby19
  3. Make sure that /opt/local/bin is in your path. If not add it.
  4. Now to use ruby1.9 you type ruby1.9 example.rb

Also additionally if you dont want to use ruby command to use the default version. You can create a simple symlink in which make the ruby at /usr/bin/ruby point to /opt/local/bin/ruby1.9.

That way your ruby version will be 1.9. However I dont recommend doing that. As there are certain gems, that might not work with 1.9, which might be affected

Shiv
can you please give direction on how to make sure that /opt/local/bin is in your path.
Ken
fire up the terminsal and type `echo $PATH`, if you see /opt/local/bin there you are fine.To ad it to your PATH this article will help `http://hayne.net/MacDev/Notes/unixFAQ.html#executionPath`
Shiv
+6  A: 

Use Ruby Version Manager. It will allow you to install most versions of Ruby and help you manage gems across them.

shinzui
+4  A: 

Install Homebrew.

brew install ruby installs ruby 1.9.1.

Debilski
this installs 1.9.2 (current version) for me but `ruby -v` still shows 1.8.7. How do I make Homebrew's version my "default"?
macek
+2  A: 

On my MacBook Pro I just did a good old compile and install. Download the 1.9.1 source from the Ruby web site (www.ruby-lang.org) and then compile. It'll install to /usr/local/bin so you will not corrupt the 1.8 if you wanted to revert back.

I never used the ports myself, but I know a lot that have/do. http://hivelogic.com/articles/ruby-rails-leopard is a good online guide for people not familiar with compiling and installing from source code.

Nicholas C
+8  A: 

rvm is easiest way to manage your ruby installation on OSX.

If you are using rvm, you will able to install 1.9.1, 1.9.2, jruby, ree by typing rvm install 1.9.1

type rvm default to reset your ruby version back to 1.8.6

How to install rvm

sudo gem install rvm -s http://gemcutter.org/

rvm-install

rvm install 1.9.1

rvm use 1.9.1

ruby -v  # show ruby 1.9.1 version

rvm default

ruby -v  # show ruby 1.8.6 version

cheers

bry4n
doesn't seem to work for me, I get an error message
Ken
And that error message is....?
Josh Pinter
Hi Bry4n,Tried but encounter a block, please help:http://stackoverflow.com/questions/3209269/about-ruby-version-manager-installation
Ken
A: 

Not sure if you ever solved this. But it sounds like 1 of 2 problems:

1. You installed the wrong ruby with MacPorts

if you just ran port install ruby, then you installed the old version, which explains why ruby -v still shows 1.8.6.

If you ran port install ruby19, then you installed ruby 1.9, but under the name ruby19. To access it, you'd have to type ruby19 in place of ruby...so ruby19 script/generate, ruby19 -v...etc.

To fix that you can do port install ruby19+nosuffix

2. you still have your PATH set to the old Ruby, which is why you're getting 1.8.6 on ruby -v.

First you gotta figure out where OSX is looking for your ruby by typing which ruby. If you're using MacPorts, that command should return /opt/local/bin/ruby. If which ruby returns /usr/bin/ruby, then it's still finding the default ruby that comes with OSX, which is 1.8.6.

To change your PATH, go open up .bash_profile, located in your user folder (if you have textmate, you can do mate ~/.bash_profile). Add in this line and save:

echo PATH="/opt/local/bin:/opt/bin:$PATH"

Basically you add the MacPorts ruby into your PATH, so the system looks for ruby in the /opt folder too. Also, maybe more importantly, you put the MacPorts path in front of the default PATH, so it will find that one first.

Goodluck with that. Personally though, I vote for Homebrew. You can find my setup for that at my blog.

funkymunky
Hi FunkyMunky,Great Blog, ran into a block, not sure if I messed up my system files already, but this is the error I get:kapplej-4:homebrew Home$ curl -L http://github.com/mxcl/homebrew/tarball/master | tar xz --strip 1 -C homebrew % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 0 121 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0tar: homebrew: Cannot chdir: No such file or directorytar: Error is not recoverable: exiting now
Ken
22 283k 22 66374 0 0 182k 0 0:00:01 --:--:-- 0:00:01 182kcurl: (23) Failed writing bodykapplej-4:homebrew Home$
Ken
Hey Ken. Not entirely sure what your error is, but the instructions on that blog are a little outdated now. For updated instructions go to the [website](http://github.com/mxcl/homebrew). I'd recommend running the script under 'Quick Install to /usr/local' unless you know what you're doing.
funkymunky
A: 

Found the answer, anyone interested please see this link:

http://stackoverflow.com/questions/3243088/answer/submit

kapplej