os x下基本上可以安装到比较新的ruby,首先先安装rvm,然后用rvm list known看当前可供安装的ruby的版本,不过这也不是绝对的,比如在我的os x 10.9上,命令返回如下:
# MRI Rubies [ruby-]1.8.6[-p420] [ruby-]1.8.7[-p374] [ruby-]1.9.1[-p431] [ruby-]1.9.2[-p320] [ruby-]1.9.3[-p484] [ruby-]2.0.0-p195 [ruby-]2.0.0[-p353] [ruby-]2.1.0 [ruby-]2.1.0-head ruby-head
可以看到最新的版本为2.1.0,为了确认这点,我们用rvm mount命令看一下:
You can specify the full url to the binaries: rvm mount -r https://rvm.io/binaries/ubuntu/12.04/x86_64/ruby-1.9.3-p194.tar.bz2
bingo!我们到https://rvm.io/binaries下看看有神马好东东:
Index of /binaries/ ../ amazon/ 07-Aug-2013 08:41 - arch/ 24-Feb-2013 14:47 - centos/ 06-Jun-2014 22:01 - debian/ 06-Jun-2014 23:32 - experimental/ 10-Nov-2013 18:28 - fedora/ 07-Jun-2014 07:29 - opensuse/ 24-Mar-2014 04:51 - osx/ 31-May-2014 00:52 - ubuntu/
自然是进入osx目录,最终我们看见了2.1.1,我们只需mount它的路径即可:
rvm mount -r https://.../ruby-2.1.1.tar.bz2
然后rvm就会下载然后自动安装,完毕后我们再将其设置为当前版本:
rvm use ruby-2.1.1
你也可以设置为默认版本:
rvm --default use ruby-2.1.1
最后我们还可以安装该版本ruby的rdoc文档以便ri查询:
rvm docs generate
然后测试一下 ri Array:
= Array < Object ------------------------------------------------------------------------------ = Includes: Enumerable (from ruby site) (from ruby site) ------------------------------------------------------------------------------ Arrays are ordered, integer-indexed collections of any object. Array indexing starts at 0, as in C or Java. A negative index is assumed to be relative to the end of the array---that is, an index of -1 indicates the last element of the array, -2 is the next to last element in the array, and so on. == Creating Arrays A new array can be created by using the literal constructor []. Arrays can contain different types of objects. For example, the array below contains an Integer, a String and a Float: ary = [1, "two", 3.0] #=> [1, "two", 3.0] An array can also be created by explicitly calling Array.new with zero, one :
有鸟,打完收工!!!
在其他linux下安装最新ruby版本与此类似,不过最后一步貌似无法完成,是rubygem服务器的问题吗?待查!