13
votes

Just trying to update to the latest version of Ruby. On ruby-lang.org/en/documentation/installation/#homebrew, I found that you should be able to do it via homebrew:

brew install ruby

However, when I listed the ruby version (ruby -v) after it 'updated' it was still at the old version 2.0.0.

Hermes:~ Sancho$ ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin13]

I happened to list the contents of /usr/local/bin/ and I could see a symbolic link:

ruby -> ../Cellar/ruby/2.2.1/bin/ruby

So, I don't know what's happening and why the version still lists the old number and not 2.2.1, as it looks like it should.

There are sym links to for various other ruby tools (erb, gem, irb, rake, rdoc, ri) to version 2.2.1 also.

So what is happening here and how do I correctly install version 2.2.1?

I do have RVM installed also, but I want to update the system version of ruby to the latest.

3
No, you don't want to do that. Apple put it there for their convenience, not yours, so leave it alone. Instead, install a separate Ruby, either using a sandbox like RVM or rbenv, or using Homebrew.the Tin Man

3 Answers

7
votes

Use Homebrew but make sure /usr/local/bin is early in your path. Ex:

.bashrc

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

This will not update the system Ruby version. Instead it will install another version of ruby and this line tells bash to look for the new version instead.

12
votes

Easy step

brew uninstall ruby # (if installed)   
brew install ruby   

then copy the path and paste into the terminal and restart the terminal
check ruby --version

enter image description here

1
votes
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile

$PATH doesn't change in current Terminal session. So please close the Terminal and reopen.

Ref: Jekyll on macOS