Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to correctly update system ruby version to latest version (2.2.1) on OSX

Tags:

macos

ruby

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.

like image 519
Plastikfan Avatar asked Mar 28 '15 15:03

Plastikfan


People also ask

How do I update my latest version of Ruby Mac?

0 was released Dec 25, 2021). Visit the Ruby releases page at the official Ruby website to check for a newer version. Mac users install the latest Ruby with Homebrew or get the latest Ruby version with the installation utilities that accompany a version manager such as asdf, chruby, rbenv, or rvm.

How do I check my Ruby version on Mac?

Pre-installed macOS system Ruby MacOS comes with a “system Ruby” pre-installed. If you see /usr/bin/ruby when you use the which command, it is the pre-installed macOS system Ruby.


2 Answers

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

like image 60
aravithapa Avatar answered Oct 12 '22 23:10

aravithapa


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.

like image 33
carloabelli Avatar answered Oct 13 '22 01:10

carloabelli