22

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.

1
  • 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. Commented Mar 28, 2015 at 18:02

4 Answers 4

21

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

0
12

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.

5
  • 1
    Ok, but is there a way to upgrade the system version? I would like the system version to be the latest version and then use RVM to use other versions of ruby as required. I would have thought this would be possible.
    – Plastikfan
    Commented Mar 28, 2015 at 16:13
  • @Shantaram I don't use RVM, but theoretically you could try to remove your system ruby and replace it, but this would be a huge hassle and I don't even know if it would work. Usually with OSX system versions you get what you get and you don't get upset Commented Mar 28, 2015 at 16:21
  • Ok cool, I'm happy with that. I'll just do as you advise and leave well alone. Thanks for that.
    – Plastikfan
    Commented Mar 28, 2015 at 16:23
  • 6
    Removing Apple's Ruby is a bad idea. They have code installed that knows it's supposed to exist there and removing it breaks that code. Just because something is visible to us and we can use it as a user doesn't mean it's there for us to play with. That's true on all OSes. Something to think about. Commented Mar 28, 2015 at 18:04
  • @theTinMan correct. Please find attached the link. It does not alter system's ruby version. Rather it creates a virtual environment using rbenv to upgrade the required ruby version. Tried and tested link: snyk.io/blog/how-to-install-ruby-in-mac-os Commented Sep 12, 2023 at 13:30
4
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

0

I followed this blog. It does not alter system's ruby version. Rather it creates a virtual environment using rbenv to upgrade the required ruby version. Tried and tested successfully.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.