我需要将Ruby版本从2.0.0更新到最新版本。我不能使用一些宝石,因为我的版本没有更新。 前段时间我用Homebrew安装了Ruby。如何更新Ruby版本?


当前回答

一种快速将Ruby升级到v2.4+的方法

brew upgrade ruby

or

sudo gem update --system

其他回答

您可以通过查看下载Ruby指定Ruby的最新版本。

获取最新版本: curl -sSL https://get.rvm.io | bash -s stable——ruby 安装: RVM安装2.2 使用它作为默认值: RVM使用2.2——default

或者运行ruby的最新命令:

rvm install ruby --latest
rvm use 2.2 --default

Brew install rbenv ruby-build

Add rbenv to bash so that it loads every time you open a terminal

Echo 'if which rbenv > /dev/null;然后eval "$(rbenv init -)";Fi ' >> ~/.bash_profile

源~ / . bash_profile

Install Ruby

Rbenv安装2.6.5

Rbenv global 2.6.5

ruby - v

Link to the

源页面

brew link --overwrite --force ruby

最简单的方法肯定是在终端输入以下命令:

sudo gem update --system

如果不想下载文档,可以添加标记——no-document。下面是运行命令后的输出示例:

sudo gem update --system
Password:
Updating rubygems-update
Fetching: rubygems-update-2.6.8.gem (100%)
Successfully installed rubygems-update-2.6.8
Parsing documentation for rubygems-update-2.6.8
Installing ri documentation for rubygems-update-2.6.8
Installing darkfish documentation for rubygems-update-2.6.8
Installing RubyGems 2.6.8
RubyGems 2.6.8 installed
Parsing documentation for rubygems-2.6.8
Installing ri documentation for rubygems-2.6.8

------------------------------------------------------------------------------

RubyGems installed the following executables:
    /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/bin/gem

Ruby Interactive (ri) documentation was installed. ri is kind of like man
pages for ruby libraries. You may access it like this:
  ri Classname
  ri Classname.class_method
  ri Classname#instance_method

一种快速将Ruby升级到v2.4+的方法

brew upgrade ruby

or

sudo gem update --system