How to update Ruby to 1.9.x on Mac?
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 Link 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.
I'll make a strong suggestion for rvm.
It's a great way to manage multiple Rubies and gems sets without colliding with the system version.
I'll add that now (4/2/2013), I use rbenv a lot, because my needs are simple. RVM is great, but it's got a lot of capability I never need, so I have it on some machines and rbenv on my desktop and laptop. It's worth checking out both and seeing which works best for your needs.
I know it's an older post, but i wanna add some extra informations about that.
Firstly, i think that rvm
does great BUT it wasn't updating ruby from my system (MAC OS Yosemite).
What rvm
was doing : installing to another location and setting up the path there to my environment variable ... And i was kinda bored, because i had two ruby now on my system.
So to fix that, i uninstalled the rvm
, then used the Homebrew package manager available here and installed ruby throw terminal command by doing brew install ruby
.
And then, everything was working perfectly ! The ruby from my system was updated ! Hope it will help for the next adventurers !
With brew this is a one-liner:
(assuming that you have tapped homebrew/versions, which can be done by running brew tap homebrew/versions
)
brew install ruby193
Worked out of the box for me on OS X 10.8.4. Or if you want 2.0, you just brew install ruby
More generally, brew search ruby
shows you the different repos available, and if you want to get really specific you can use brew versions ruby
and checkout a specific version instead.