Upgrade Ruby to the lastest version on Mac OSX with brew
Recently when installing some gems, they poped out errors that the Ruby version is lower than required… I have to upgrade the shipped Ruby, version 2.0.0p648 (2015-12-16 revision 53162), on my OS. There are a few methods dealing with this, but I found the easiest way is using Homebrew.
Check current version of Ruby
Type following line in terminal:
ruby 2.0.0p648 (2015-12-16 revision 53162) [universal.x86_64-darwin16] on macOS Sierra, quite old 🤔.
Homebrew is a package manager for macOS, just like apt for Ubuntu. You can install a number of open source software with it.
Paste the following line at the terminal to install Homebrew:
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
Install Ruby with Homebrew
brew install ruby
One simple line is enough, Homebrew installs the stuff you need without any further configuration.
After install finished, just restart your terminal and check the version of Ruby with
ruby -v, that will show you the lastest stable version (for now, it’s ruby 2.4.2p198).
It’s better to update the bundler with
gem install bundler to handle installed gems.