一直不知道rvm有一個(gè)mount功能,這次使用rvm自動安裝jruby一直不成功,結(jié)果通過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中,方便統(tǒng)一的管理。
rvm automount可以自動加載在PATH環(huán)境變量中能識別的Ruby。
比如經(jīng)常因?yàn)楸粔Φ脑颍瑹o法下載ruby的源碼進(jìn)行本地編譯,rvm安裝ree經(jīng)常失敗,還有我這次遇到的安裝jruby總是編譯失敗,那么解決的方法就很簡單,在jruby的官網(wǎng)下載已編譯好的版本,解壓到本地,/opt/jruby/,然后再rvm mount /opt/jruby即可!
rvm會自動識別版本,然后創(chuàng)建一個(gè)ext-開頭的Ruby版本,隨時(shí)可以通過rvm use ext-jruby-xxx來使用了。