Home  >  Q&A  >  body text

Mac 上brew install ruby 成功安装ruby-2.2.3 但是打ruby -v 依然显示2.0.0

如题!

请教是怎么回事?

伊谢尔伦伊谢尔伦2759 days ago862

reply all(5)I'll reply

  • 天蓬老师

    天蓬老师2017-04-24 09:13:01

    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]

    reply
    0
  • PHP中文网

    PHP中文网2017-04-24 09:13:01

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

    reply
    0
  • PHP中文网

    PHP中文网2017-04-24 09:13:01

    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. .

    reply
    0
  • 大家讲道理

    大家讲道理2017-04-24 09:13:01

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

    reply
    0
  • ringa_lee

    ringa_lee2017-04-24 09:13:01

    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

    reply
    0
  • Cancelreply