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