如何使用 Homebrew 更新 Ruby?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/36485180/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 06:48:44  来源:igfitidea点击:

How to update Ruby with Homebrew?

rubymacoshomebrew

提问by Ralph David Abernathy

I want to know how to update to the latest stableversion of Ruby with Homebrew. I am notinterested in using RVM. Thanks.

我想知道如何使用 Homebrew更新到最新的稳定版 Ruby。我对使用 RVM感兴趣。谢谢。

回答by spickermann

I would use ruby-buildwith rbenv. The following lines install Ruby 2.7.1 and set it as your default Ruby version:

我会用ruby-buildrbenv。以下几行安装 Ruby 2.7.1 并将其设置为您的默认 Ruby 版本:

$ brew update
$ brew install ruby-build
$ brew install rbenv

$ rbenv install 2.7.1
$ rbenv global 2.7.1

回答by Gustavo Rubio

brew upgrade ruby

brew upgrade ruby

Should pull latest version of the package and install it.

应该拉取最新版本的软件包并安装它。

brew updateupdates brew itself, not packages (formulas they call it)

brew update更新 brew 本身,而不是包(他们称之为公式)

回答by ovisirius

Adding to the selected answer (as I haven't enough rep to add comment), one way to see the list of available versions (from ref) try:

添加到选定的答案(因为我没有足够的代表来添加评论),查看可用版本列表的一种方法(来自 ref)尝试:

$ rbenv install -l

回答by ltrainpr

To upgrade Ruby with rbenv: Per the rbenv README

使用 rbenv 升级 Ruby:根据rbenv README

  • Update first: brew upgrade rbenv ruby-build
  • See list of Ruby versions: versions available: rbenv install -l
  • Install: rbenv install <selected version>
  • 先更新: brew upgrade rbenv ruby-build
  • 查看 Ruby 版本列表:可用版本: rbenv install -l
  • 安装: rbenv install <selected version>

回答by Devesh

open terminal

打开终端

\curl -sSL https://get.rvm.io | bash -s stable

\curl -sSL https://get.rvm.io | bash -s stable

restart terminal then

然后重启终端

rvm install ruby-2.4.2

check ruby version it should be 2.4.2

检查 ruby​​ 版本它应该是 2.4.2