Mac 上brew install ruby 成功安装ruby-2.2.3 但是打ruby -v 依然显示2.0.0
伊谢尔伦
伊谢尔伦 2017-04-24 09:11:01
0
5
873

如题!

请教是怎么回事?

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(5)
Peter_Zhu

You can look at it like this

type ruby

The result should be

/usr/bin/ruby

This is ruby2.0 pre-installed on the system

Use brew install ruby ​​and it will be installed in the /usr/local/Cellar/ruby/2.2.3/bin/rubypath

ruby -v
ruby 2.0.0p481 (2014-05-08 revision 45883) [universal.x86_64-darwin14]
@caoh ➜  ~  /usr/local/Cellar/ruby/2.2.3/bin/ruby -v
ruby 2.2.3p173 (2015-08-18 revision 51636) [x86_64-darwin14]
洪涛

It is best to use RVM to install Ruby on mac, which is convenient for management and does not require sudo permissions

洪涛

Just configure the environment variables under your bash_profile. .

But still use rvm to install, otherwise you may encounter strange problems: the original system version will appear inexplicably. .

大家讲道理

It’s a matter of path, just change your bash path.

左手右手慢动作

You first use brew info ruby命令看一下有几个版本
然后用brew switch ruby 版本号 就可以切换到指定版本
比如
brew switch ruby 2.2.3
to switch to version 2.2.3
In fact, brew just redoes the soft link

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template