Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to update Ruby to 1.9.x on Mac?

I have created a new user account on my mac and I am trying to update to the current version of ruby on it (1.9.2) from the snow leopard default of 1.8.7. Can somebody point me to tutorial or explain the best method to update Ruby on my mac from 1.8 to 1.9.2? Thanks

like image 251
ab217 Avatar asked Sep 12 '10 20:09

ab217


People also ask

How do I check my Ruby version on Mac?

How to check Ruby version on Mac. Don't type the $ character. The $ character is just a cue that you should enter a shell command. The ruby -v command will show you the Ruby version number.


1 Answers

As The Tin Man suggests (above) RVM (Ruby Version Manager) is the Standard for upgrading your Ruby installation on OSX: https://rvm.io

To get started, open a Terminal Window and issue the following command:

\curl -L https://get.rvm.io | bash -s stable --ruby 

( you will need to trust the RVM Dev Team that the command is not malicious - if you're a paranoid penguin like me, you can always go read the source: https://github.com/wayneeseguin/rvm ) When it's complete you need to restart the terminal to get the rvm command working.

rvm list known 

( shows you the latest available versions of Ruby )

rvm install ruby-2.3.1 

For a specific version, followed by

rvm use ruby-2.3.1 

or if you just want the latest (current) version:

rvm install current && rvm use current 

( installs the current stable release - at time of writing ruby-2.3.1 - please update this wiki when new versions released )

Note on Compiling Ruby: In my case I also had to install Homebrew http://mxcl.github.com/homebrew/ to get the gems I needed (RSpec) which in turn forces you to install Xcode (if you haven't already) https://itunes.apple.com/us/app/xcode/id497799835 AND/OR install the GCC package from: https://github.com/kennethreitz/osx-gcc-installer to avoid errors running "make".

Edit: As of Mavericks you can choose to install only the Xcode command line tools instead of the whole Xcode package, which comes with gcc and lots of other things you might need for building packages. It can be installed by running xcode-select --install and following the on-screen prompt.

  • Examples: https://rvm.io/workflow/examples/
  • Screencast: http://screencasts.org/episodes/how-to-use-rvm

Note on erros: if you get the error "RVM is not a function" while trying this command, visit: How do I change my Ruby version using RVM? for the solution.

like image 58
8 revs, 5 users 81% Avatar answered Sep 28 '22 04:09

8 revs, 5 users 81%