我需要将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 terminalEcho 'if which rbenv > /dev/null;然后eval "$(rbenv init -)";Fi ' >> ~/.bash_profile
源~ / . bash_profile
Install RubyRbenv安装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
推荐文章
- 如何记录Ruby代码?
- Ruby:包含的反义词是什么?Ruby数组?
- 在Ruby中,proc和lambda有什么区别?
- 如何传递参数到一个Rake任务与环境在Rails?
- 获取当前正在执行的方法的名称
- 如何在Rails中计算相对时间?
- 在Ruby中使用范围填充数组的正确方法
- “for”和“each”在Ruby中
- 我如何复制一个哈希在Ruby?
- Ruby/Rails:将Date转换为UNIX时间戳
- 我如何编码/解码HTML实体在Ruby?
- Ruby有一个string. startwith ("abc")内置方法吗?
- 如何从URL下载文件并保存在Rails中?
- 从字符串中移除子字符串
- 如何从Ruby数组中创建平均值?