rvm mount

一直不知道rvm有一个mount功能,这次使用rvm自动安装jruby一直不成功,结果通过mount搞定,和大家分享一下。

首先看看rvm help mount说了些什么:

# rvm help mount
Usage:

    rvm automount
    rvm mount /path/to/ruby [-n {name}]
    rvm mount [-r] {https://url/to/ruby.tar.bz2} [name]


## Mounting local compiled rubies

RVM supports adding rubies compiled by user.

If compiled ruby is already on `PATH` then use:

    rvm automount

If ruby is not on `PATH` and was compiled in `/opt/ruby-1.9.3-p194`,
then both following commands will add it to RVM:

    rvm mount /opt/ruby-1.9.3-p194
    rvm mount /opt/ruby-1.9.3-p194/bin/ruby

RVM will ask user for the name for it, for automation you can use `-n` flag:

    rvm mount /opt/ruby-1.9.3-p194 -n ruby-1.9.3-p194

Which will create `ext-ruby-1.9.3-p194`, the `ext-` prefix is there to
distinguish externally compiled rubies.

rvm mount的功能是加载安装本地已有编译好的Ruby版本到rvm中,方便统一的管理。

rvm automount可以自动加载在PATH环境变量中能识别的Ruby。

比如经常因为被墙的原因,无法下载ruby的源码进行本地编译,rvm安装ree经常失败,还有我这次遇到的安装jruby总是编译失败,那么解决的方法就很简单,在jruby的官网下载已编译好的版本,解压到本地,/opt/jruby/,然后再rvm mount /opt/jruby即可!

rvm会自动识别版本,然后创建一个ext-开头的Ruby版本,随时可以通过rvm use ext-jruby-xxx来使用了。

你可能感兴趣的:(rvm mount)