跳到主要內容

Ruby on RVM

RVM 的全名是 ruby version manager,是一套用來管理 ruby 版本的套件。Ubuntu 預設就有安裝 ruby 且系統會使用,而 ruby 每個版本可能存在蠻大的差異,如果在系統上安裝許多版本的 ruby ,會讓系統感覺很混亂,移除又擔心影響系統穩定度,這時用 rvm 再好也不過了!

在安裝 rvm 之前,系統上必需要有一套 ruby,不過 ubuntu 預設就安裝了,很好 :D
參考安裝手冊
$ sudo apt-get install curl git-core
$ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)

完成後,系統會告訴我們一些訊息,如下:
Notes for Linux ( DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=8.04
DISTRIB_CODENAME=hardy
DISTRIB_DESCRIPTION="Ubuntu 8.04.4 LTS" )

NOTE: 'ruby' represents Matz's Ruby Interpreter (MRI) (1.8.X, 1.9.X)
This is the *original* / standard Ruby Language Interpreter
'ree' represents Ruby Enterprise Edition
'rbx' represents Rubinius

bash >= 3.2 is required
curl is required
git is required (>= 1.7 recommended)
patch is required (for ree and some ruby-head's).

If you wish to install rbx and/or Ruby 1.9 head (MRI) (eg. 1.9.2-head),
then you must install and use rvm 1.8.7 first.

If you wish to have the 'pretty colors' again,
set 'export rvm_pretty_print_flag=1' in ~/.rvmrc.

dependencies:
# For RVM
rvm: bash curl git

# For Ruby (MRI & ree) you should install the following OS dependencies:
ruby: /usr/bin/aptitude install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev

# For JRuby (if you wish to use it) you will need:
jruby: /usr/bin/aptitude install curl g++ openjdk-6-jre-headless
jruby-head: /usr/bin/aptitude install ant openjdk-6-jdk

# In addition to ruby: dependencies,
ruby-head: subversion

# For IronRuby (if you wish to use it) you will need:
ironruby: /usr/bin/aptitude install curl mono-2.0-devel

You must now complete the install by loading RVM in new shells.

1) Place the folowing line at the end of your shell's loading files
(.bashrc or .bash_profile for bash and .zshrc for zsh),
after all PATH/variable settings:

[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.

You only need to add this line the first time you install rvm.

2) Ensure that there is no 'return' from inside the ~/.bashrc file,
otherwise rvm may be prevented from working properly.

This means that if you see something like:

'[ -z "$PS1" ] && return'

then you change this line to:

if [[ -n "$PS1" ]] ; then

# ... original content that was below the '&& return' line ...

fi # <= be sure to close the if at the end of the .bashrc.


# This is a good place to source rvm v v v
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.

EOF - This marks the end of the .bashrc file

Be absolutely *sure* to REMOVE the '&& return'.

If you wish to DRY up your config you can 'source ~/.bashrc' at the bottom of your .bash_profile.

Placing all non-interactive (non login) items in the .bashrc,
including the 'source' line above and any environment settings.

3) CLOSE THIS SHELL and open a new one in order to use rvm.

WARNING: you have a 'return' statement in your ~/.bashrc
This could cause some features of RVM to not work.

This means that if you see something like:

'[ -z "$PS1" ] && return'

then you change this line to:

if [[ -n "$PS1" ]] ; then

# ... original content that was below the '&& return' line ...

fi # <= be sure to close the if at the end of the .bashrc.


# This is a good place to source rvm v v v
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.

EOF - This marks the end of the .bashrc file

Even if you are using zsh you should still adjust the ~/.bashrc
If you have any questions about this please visit
#rvm on irc.freenode.net.

Installation of RVM to /home//.rvm/ is complete.


Thank you very much for using RVM! I sincerely hope that RVM helps to
make your work both easier and more enjoyable.

If you have any questions, issues and/or ideas for improvement please
join#rvm on irc.freenode.net and let me know, note you must register
(http://bit.ly/5mGjlm) and identify (/msg nickserv ) to
talk, this prevents spambots from ruining our day.

My irc nickname is 'wayneeseguin' and I hang out in #rvm typically

~09:00-17:00EDT and again from ~21:00EDT-~23:00EDT

If I do not respond right away, please hang around after asking your
question, I will respond as soon as I am back. It is best to talk in
#rvm itself as then other users can help out should I be offline.

Be sure to get head often as rvm development happens fast,
you can do this by running 'rvm get head' followed by 'rvm reload'
or opening a new shell

w⦿‿⦿t

~ Wayne


這些資訊是要閱讀的,不可以忽略,它會提示我們有哪些相依的套件是需要安裝和設定。

以 install ruby 來說,它告訴我們需要做:
# /usr/bin/aptitude install build-essential bison openssl libreadline6 libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libsqlite3-0 libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev

然後在 ~/.bashrc 把下面這一行加進去
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # This loads RVM into a shell session.


都完成之後,以後只要透過 rvm 就可以輕易切換 ruby 版本了!

留言

這個網誌中的熱門文章

[lyrics] Imagine

Title: Imagine Artist: John Lennon Imagine there's no Heaven It's easy if you try No hell below us Above us only sky Imagine all the people Living for today Imagine there's no countries It isn't hard to do Nothing to kill or die for And no religion too Imagine all the people Living life in peace You may say that I'm a dreamer But I'm not the only one I hope someday you'll join us And the world will be as one Imagine no possessions I wonder if you can No need for greed or hunger A brotherhood of man Imagine all the people Sharing all the world You may say that I'm a dreamer But I'm not the only one I hope someday you'll join us And the world will live as one ----------------------------- 這首歌和歌詞是早就知道的,最近又再次聽起它並認真的讀了歌詞 真的,很感動,多麼美好的世界~ (遠目) 真的也無法形容浮現在腦中的畫面.... 只能用心來感受它吧! 同樣的東西在不同的時間下會有新的,全然不同的感受.... 也有許多事情,是要親自走過、痛過、經歷過,才能了解那份感受 寫這個沒什麼意義,只是紀錄當下的感覺罷了!

白揚瀑布

 

健保卡代號

IC卡載入後,欄位代碼之表示為: *(1)代表「同意器官捐贈,不同意安寧緩和醫療」 *(4)代表「同意器官捐贈,同意安寧緩和醫療,同意不 施行心肺復甦術」 *(7)代表「不同意器官捐贈,同意安寧緩和醫療,同意 不施行心肺復甦術」 *未註記 p.s: 今天看牙醫順便請醫生幫我看一下,醫生說是代號(4),簽成功了 :) ref: http://www.tho.org.tw/xms/read_attach.php?id=259