简体   繁体   中英

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

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.

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

在此处输入图片说明

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM