在安装 Ruby on Rails 时遇到问题,提示依赖 ruby 2.2.2 或更高的版本。

ERROR:  Error installing rails:
	activesupport requires Ruby version >= 2.2.2.

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px '.PingFang SC'; color: #454545}
span.s1 {font: 12.0px 'Helvetica Neue'}

一、使用RVM也就是Ruby Version Manager,Ruby版本管理器来升级rubyRVM包含了Ruby的版本管理和Gem库管理(gemset)。(以下命令都在终端中进行,因为基本都是命令行  我就不上图了,终端的提示也比较清晰)

1、安装RVM

$ curl -L get.rvm.io | bash -s stable

命令输出:

Downloading https://github.com/rvm/rvm/archive/1.29.2.tar.gz
Downloading https://github.com/rvm/rvm/releases/download/1.29.2/1.29.2.tar.gz.asc
Found PGP signature at: 'https://github.com/rvm/rvm/releases/download/1.29.2/1.29.2.tar.gz.asc',
but no GPG software exists to validate it, skipping.

Installing RVM to /Users/aven/.rvm/
    Adding rvm PATH line to /Users/aven/.profile /Users/aven/.mkshrc /Users/aven/.bashrc /Users/aven/.zshrc.
    Adding rvm loading line to /Users/aven/.profile /Users/aven/.bash_profile /Users/aven/.zlogin.
Installation of RVM in /Users/aven/.rvm/ is almost complete:

  * To start using RVM you need to run `source /Users/aven/.rvm/scripts/rvm`
    in all your open shell windows, in rare cases you need to reopen all shell windows.

# aven,
#
#   Thank you for using RVM!
#   We sincerely hope that RVM helps to make your life easier and more enjoyable!!!
#
# ~Wayne, Michal & team.

In case of problems: https://rvm.io/help and https://twitter.com/rvm_io

  * WARNING: You have '~/.profile' file, you might want to load it,
    to do that add the following line to '/Users/aven/.bash_profile':

      source ~/.profile

可以看到最后有一条警告,需要执行:

source ~/.profile

主要作用应该就是更新环境变量。

2、测试是否安装成功

rvm -v

直接执行 rvm 不带参数会显示帮助信息。

<a href="https://www.bountysource.com/teams/rvm?utm_source=RVM&utm_medium=shield&utm_campaign=raised"><img src="https://api.bountysource.com/badge/team?team_id=506&style=raised" align="center"></a>
    
Master
<a href="https://travis-ci.org/rvm/rvm/branches"><img src="https://travis-ci.org/rvm/rvm.svg?branch=master" align="center"></a>

# What's RVM

RVM is the acronym of Ruby enVironment Manager. It manages Ruby application environments and enables switching between them.

Homepage and more info: https://rvm.io/

## Installing RVM

### Ubuntu

RVM have dedicated Ubuntu package, so please follow instructions posted here: https://github.com/rvm/ubuntu_rvm

If you need a different (newer) version of RVM, after installing base version of RVM check the [Upgrading](#upgrading) section below. 

### Any other operating system

Make sure you have following required packages installed:

* `curl`

And then run:

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

### Additional installation options

Additional installation options and details about the installation process are described here: https://rvm.io/rvm/install

## Upgrading RVM

You can upgrade RVM any time by running:

`rvm get VERSION`

Where `VERSION` should be replaced by one of the following values:

* `stable`              - latest stable RVM (good for servers)
* `master`              - latest RVM (might not be stable)
* `branch /path/branch` - branched version of RVM (for testing new features or bug fixes)

Additional upgrading options are described here: https://rvm.io/rvm/upgrading

## Basic RVM usage

Basic RVM usage scenarios include installing and switching between different ruby versions.

### Installing ruby

To install ruby you have to call `rvm install INTERPRETER[-VERSION] OPTIONS` 

When no version specified, RVM will install latest stable version or selected interpreter. If you omit to specify interpreter, RVM will assume
that you wanted to install MRI ruby. Following examples would have exactly the same effect:    

```
rvm install ruby-2.3.1
rvm install ruby-2.3
rvm install 2.3.1
rvm install 2.3
```

Passing additional `--default` option makes selected ruby your default. 

We currently supported following ruby interpreters:

* `ruby`       - MRI ruby (The Gold Standard)
* `ironruby`   - a .NET ruby
* `jruby`      - Java implementation of the ruby
* `macruby`    - implementation of ruby 1.9 directly on top of macOS core technologies
* `maglev`     - 64-bit implementation on top of VMware's GemStone
* `mruby`      - lightweight ruby
* `opal`       - ruby to JavaScript compiler
* `rbx`        - Rubinius - a next generation virtual machine VM for ruby
* `topaz`      - high performance ruby, written in RPython

Historical interpreters which you can still install with RVM, but are not anymore developed and supported by their authors:

* `ree`        - Ruby Enterprise Edition - MRI Ruby with several custom patches for performance, stability, and memory

### Switching between ruby versions

To switch between ruby versions you should call

`rvm use INTERPRETER[-VERSION]`

Same rules and options apply as for `install` command with two special _interpreters_. 

* `default`    - [default](https://rvm.io/rubies/default/) ruby (or the system ruby if a default hasn't been set)
* `system`     - system ruby (state before RVM was installed)

Additionally you might want list your preferred ruby version in `.ruby-version` file stored in your project folder. This would cause automatic switch to selected ruby whenever you enter the folder.  

### Other RVM commands

RVM comes bundled with many different tools for managing your ruby environment. More detailed information about every commands listed below can be read after executing `rvm help COMMAND` or browsing documentation on RVM homepage https://rvm.io/.

#### Installation

* `implode`              - removes the rvm installation completely. This means everything in `$rvm_path` (`~/.rvm` || `/usr/local/rvm`). This does not touch your profiles. However, this means that you must manually clean up your profiles and remove the lines which source RVM
* `install`              - [install](https://rvm.io/rubies/installing/) one or many ruby versions
* `list`                 - show currently installed rubies, interactive output - https://rvm.io/rubies/list/
* `mount`                - install rubies from external locations
* `patchset`             - tools related to managing ruby patchsets
* `pkg`                  - install a dependency package `{readline,iconv,zlib,openssl}` - https://rvm.io/packages/
* `reinstall`            - reinstall ruby and runs `gem pristine` on all gems. Make sure to read output. Use `all` for all rubies
* `reload`               - reload rvm source itself (useful after changing rvm source).
* `remove`               - uninstall one or many ruby versions and remove their sources
* `requirements`         - installs additional OS specific dependencies/requirements for building various rubies (by default run by `install`)
* `reset`                - remove current and stored default & system settings
* `snapshot`             - lets you backup / restore an rvm installation in a lightweight manner
* `uninstall`            - uninstall one or many ruby versions, keeping their sources
* `upgrade`              - lets you upgrade from one version of a ruby to another, including migrating your gemsets semi-automatically

#### Running different ruby versions

* `do`                   - runs an arbitrary command against specified and/or all rubies
* `use`                  - setup current shell to use a specific ruby version

#### Managing gemsets

* `gemset`               - manage [gemsets](https://rvm.io/gemsets/)
* `migrate`              - lets you migrate all gemsets from one ruby to another

#### Configuration

* `alias`                - define aliases for `rvm use`
* `autolibs`             - control settings for installing dependencies automatically
* `current`              - print the current ruby version and the name of any gemset being used
* `gemdir`               - display the path to the current gem directory (`GEM_HOME`)
* `group`                - tools for managing groups in multiuser installations
* `rvmrc`                - tools related to managing `.rvmrc` trust and loading
* `wrapper`              - generates a set of wrapper executables for a given ruby with the specified ruby and gemset combination. Used under the hood for passenger support and the like

#### Maintenance

* `cleanup`              - remove stale source folders / archives and other miscellaneous data associated with rvm
* `cron`                 - manage setup for using ruby in cron
* `disk-usage`           - display disk space occupied by RVM
* `docs`                 - tools to make installing ri and rdoc documentation easier
* `fetch`                - download binary or sources for selected ruby version
* `get`                  - upgrades RVM to latest head, stable or branched version
* `osx-ssl-certs`        - helps update certificates for OpenSSL installed by rvm on OSX

#### Troubleshooting

* `config-get`           - display values for `RbConfig::CONFIG` variables
* `debug`                - show additional information helping to discover common issues
* `export`               - temporarily set an environment variable in the current shell
* `fix-permissions`      - repairs broken permissions
* `repair`               - lets you repair parts of your environment e.g. wrappers, env files and similar (e.g. general maintenance)
* `rubygems`             - switches the installed version of rubygems for the current ruby
* `tools`                - provides general information about the ruby environment, primarily useful when scripting rvm
* `unexport`             - undo changes made to the environment by `rvm export`
* `user`                 - tools for managing RVM mixed mode in multiuser installations

#### Information and documentation

* `info`                 - show the environment information for current ruby
* `notes`                - display notes with operating system specifics
* `usage`                - list available commands and their usage info (content of this README)
* `version`              - display rvm version (equal to `rvm -v`) 

### Additional global options

* `--debug`           - toggle debug mode on for very verbose output
* `--trace`           - toggle trace mode on to see EVERYTHING rvm is doing
* `--nice`            - process niceness (increase the value on slow computers, default `0`)
* `-v` | `--version`  - display rvm version loaded for current shell

## Reporting issues

Here at RVM we get a high amount of bug reports, and often they are connected
with specific environment settings which might be hard for us to replicate.
That's why we would kindly ask you to follow the steps below so we can maximize
our time helping you and minimize the time requesting more information.

### Check documentation

We know, you hear this over and over and be rest assured we are working hard to improve the
usability of https://rvm.io but we must always ask that you first please check the documentation
if you are requesting a feature or if you are not sure if you did it right.

### Try again with latest RVM

We try to release a new RVM as soon as we feel that we achieved certain stability. This might take
a while and it could be the case that your issue has been already resolved in our development branch.
Please get the latest RVM and try again:

`rvm get master`

### File an issue

If the documentation is not clear, an error message is not clear or you are stuck with the problem,
please do file a bug.

When in doubt as to whether your issue might relate to another, simply file a new bug, and
we will mark it as duplicate if it needs to be.  It's always better to file a new ticket and
let us sort it out than to accidentally add noise to another ticket.

For filing issues, we have prepared a template for you to use. Please try to fill all sections as best as you can.
Always make sure to split up each command and its output into its own fenced code block.
If the output is long, please put it in a separate [gist](https://gist.github.com).
Otherwise it's hard for us to process all the information and respond quickly.

Note that if there is a lot of `debug` or `trace` output you can redirect it to a file with the `>`
character like `rvm [command] > output.txt`.

## Contributing

You are very warmly welcome to help. Please follow our [contribution guidelines](CONTRIBUTING.md) 

Any and all contributions offered in any form, past present or future are understood to be in complete agreement and acceptance with the [Apache License](LICENSE) v2.0.

## License

Copyright (C) Michal Papis (2011-2017), Piotr Kuczynski (2016-2017), Wayne E. Seguin (2009-2011) 

Licensed under the [Apache License](LICENSE), Version 2.0

  Action documentation available with 'rvm help action-name':

      alias autolibs cleanup config-get cron current debug disk-usage do docs fetch fix-permissions gemdir gemset gemset/copy get group implode info install list migrate mount notes osx-ssl-certs patchset pkg prepare reinstall remove repair requirements reset rubygems rvmrc rvmrc/to rvmrc/warning snapshot srcdir tools uninstall upgrade use user wrapper 

  Other topics of documentation available with 'rvm help topic':

      alt color upgrade-notes 

  For additional information please visit RVM's documentation website: https://rvm.io/

$ rvm -v
rvm 1.29.2 (latest) by Michal Papis, Piotr Kuczynski, Wayne E. Seguin [https://rvm.io/]

二、使用RVM升级Ruby

1、查看当前ruby版本

ruby -v

p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px '.PingFang SC'; color: #454545}
span.s1 {font: 12.0px 'Helvetica Neue'}

2、列出已知ruby的版本

rvm list known

稍等一下,会出现很多平台不同的ruby的版本,由于要求 2.2.2 以上,所以也别选太高的版本,避免不兼容,就选一个相对稳定的版本。

3、安装指定版本

rvm install ruby-2.2.6

4、安装完之后,可以ruby -v 测试一下,查以看到已经是 2.2.6 了。
安装过程中的部分输出需要关注一下:

Searching for binary rubies, this might take some time.
No binary rubies available for: osx/10.12/x86_64/ruby-2.2.6.
Continuing with compilation. Please read 'rvm help mount' to get more information on binary rubies.
Checking requirements for osx.
Installing requirements for osx.
Updating system..........................................................................|
Installing required packages: autoconf, automake, libtool, coreutils, libyaml, libksba...|
Updating Homebrew...
==> Upgrading 3 outdated packages, with result:
openssl 1.0.2l, pkg-config 0.29.2, readline 7.0.3_1
==> Upgrading openssl
==> Downloading https://homebrew.bintray.com/bottles/openssl-1.0.2l.sierra.bottle.tar.gz
######################################################################## 100.0%
==> Pouring openssl-1.0.2l.sierra.bottle.tar.gz
==> Using the sandbox
==> Caveats

从输出可以看出 RVM 实际使用了 Homebrew 。

好了,更新完了,去做你想做的事吧。

macOS Ruby版本需要升级到2.2.2以上的更多相关文章

  1. 关于IOS新手在安装cocoa pods失败,因为ruby版本过低的解决方法+ (void) {升级ruby}

    http://blog.csdn.net/zhaoen95/article/details/51995520     现在: 使用 OS 系统, 正在学习iOS 需要配置cocoapods 命令行中显 ...

  2. macos下使用rvm管理ruby版本和rails版本

    1. 安装rvm curl -L https://get.rvm.io | bash -s stable 查看rvm 版本 2. 安装ruby rvm install 2.3.1 查看ruby 版本 ...

  3. 【转】如何在Mac 终端升级ruby版本

    原文网址:https://segmentfault.com/a/1190000003784636 rvm是什么?为什么要安装rvm呢,因为rvm可以让你拥有多个版本的Ruby,并且可以在多个版本之间自 ...

  4. cocoapods安装以及使用,安装过程中ruby版本过低

    cocoapods安装以及使用,安装过程中ruby版本过低 字数473 阅读103 评论1 喜欢2 1.打开终端 2.移除现有 Ruby 默认源 $ gem sources --remove http ...

  5. MAC Ruby版本需要升级至2.2.2以上

    第一例: 默认情况下,Mac OS X 系统已经安装好 Ruby(最新的 Mavericks 随机的 Ruby 版本为 2.0.0p247),安装在 /System/Library/Framework ...

  6. 零零碎碎搞了一天最后发现是ruby版本问题

    查来查去查不到问题,后来在stackoverflow看到: http://stackoverflow.com/questions/22352838/ruby-gem-install-json-fail ...

  7. Nginx1.8.0版本平滑升级新版本1.9.7

    原文:http://www.jb51.net/article/79878.htm 首先查看现在环境nginx的版本为1.8.0 编译的参数只指定了安装路径: 复制代码代码如下: [root@local ...

  8. SequoiaDB版本在线升级介绍说明

    1.前言 在SequoiaDB数据库发展过程中,基本保持每半年对外发行一个正式的Release版本.并且每个新发布的Release版本相对老版本而言,性能方面都有很大的提高,并且数据库也会在新版本中加 ...

  9. PostgreSQL版本快速升级

    PostgreSQL版本快速升级 写在前面 PostgreSQL9.5版本支持数据分片的功能,为以后做分布式考虑,准备将生产环境的9.1版本升级至9.5.中间需要做数据迁移. 在迁移操作中,为保证数据 ...

随机推荐

  1. C语言高级宏技巧

    特殊符号#.## (1)# When you put a # before an argument in a preprocessor  macro, the preprocessor turns t ...

  2. PHP数组的创建

    案例: 仔细看代码,PHP创建数组 <?php $names[0]='Peter'; $names[1]='Minot'; $names[2]='Smith'; echo $names[0].' ...

  3. IOS中快速集成短信SDK验证开发(SMSSDK),IOS开发中如何设置手机验证码

    [转载请注明出处] sdk是别人的,我只是下载来集成一下. smssdk下载网站:http://www.mob.com/(也有其他很多网站有类似SDK,譬如https://www.juhe.cn/等等 ...

  4. 表单向controller传值如果没填controller取到的是null

    jsp前端表单,向controller传数据,如果没有值,后台传入的是null,比如checkbox未选中,后台设置的Integer[] ids,接收到的ids=null,hidden标签如果没有值, ...

  5. cdojQ - 昊昊爱运动 II

    地址:http://acm.uestc.edu.cn/#/contest/show/95 题目: Q - 昊昊爱运动 II Time Limit: 3000/1000MS (Java/Others) ...

  6. Javascript中call()和apply()的用法 ----1

    1.方法定义 call方法: 语法:call([thisObj[,arg1[, arg2[,   [,.argN]]]]]) 定义:调用一个对象的一个方法,以另一个对象替换当前对象. 说明: call ...

  7. 【Java】Swing+IO流实现一个简单的文件加密程序(demo版)

    留着参考 EncrytService package com.my.service; import java.io.File; import java.io.FileInputStream; impo ...

  8. 抗DDOS攻击

    2016年10月的某天,“半个美国互联网”都瘫痪了,就是因为遭受了DDoS攻击——Twitter.GitHub.Spotify.Airbnb.Etsy等大量站点都因此受到影响.DNS服务提供商Dyn公 ...

  9. Codeforces Round #364 (Div. 2) C. They Are Everywhere 尺取法

    C. They Are Everywhere time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  10. Tomcat出现java.lang.Exception: Socket bind failed

    今天测试系统,Tomcat(apache-tomcat-6.0.20windows版)突然出现异常,导致JSP页面无法运行.错误提示如下:2014-3-12 17:13:29 org.apache.c ...