Mac自身的ruby 版本 2.x,通过ruby -v可以查看版本号。

为更新到ruby的最新版本,可通过以下命令解决:
brew update
我们发现已经是最新版本可继续进行下一步。

brew install ruby

执行完命令后,ruby -v后其实还是原来的版本👌,这是因为环境变量没有配置。因此,还有一个步骤就是配置环境变量。
执行以下两步就OK了
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.bash_profile
source ~/.bash_profile
执行后,查看版本后,会判断已更新到最新版本。

网友评论