Setting Ruby to version 1.9.3 as default in Mac OS X Lion


RVM (Ruby Version Manager) is a Ruby interpreter, version management tool. It enables you to switch between different versions and releases of Ruby (for instance, version 1.8.7, ruby enterprise edition) on the same machine, while associating different gems with each version of the ruby interpreter. If you want to play with Rails 3 and Ruby 1.9.x, and then want to switch back to your previous developed apps, which are running on Rails 2.3.x and Ruby 1.8.x, you can do so with a single command from the terminal.

1. Installing RVM and edit profile scripts

First, use the following bash script to install RVM:
$ bash << (curl -s https://rvm.beginrescueend.com/install/rvm)

Next you have to add rvm to your .bashrc profile
[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm" # Load RVM function
[[ -r $rvm_path/scripts/completion ]] && . $rvm_path/scripts/completion #rvm tab completion

And run the following command in terminal:
$ source ~/.bashrc

To check everything went well:
$ type rvm | head -n1

Should tell you “rvm is a function”

Now install openssl package and latest Ruby version (1.9.3):

$ rvm package install readline
$ rvm package install iconv
$ rvm package install zlib

$ rvm pkg install openssl

$ rvm install ruby-1.9.3 --with-readline-dir=$rvm_path/usr --with-iconvdir=$rvm_path/usr --with-zlib-dir=$rvm_path/usr --with-openssl-dir=$rvm_path/usr --with-gcc=clang

Ultimately, make sure that the system version of Ruby is ok:
$ ruby -v

That should return your system Ruby version, which as of this writing is 1.8.7 with Mac OS X Leopard and Mac OS X Lion.
ruby 1.8.7 (2010-08-16 patchlevel 302) [i686-darwin10]

2. Set Ruby to default to version 1.9.3

Now, let’s use RVM to se the default Ruby interpreter to 1.9.3:

$ rvm use 1.9.3 --default

Now type ruby -v again and that should return version 1.9.3:
ruby 1.9.3p0 (2011-10-30 revision 33570) [x86_64-darwin11.2.0]

You can also get back to where you started and revert to using your original Ruby setup (not using RVM) with a single command:

$ rvm system

Done. Have fun :)

熱門文章

Nov 2024【陽明山溫泉】老字號「馬槽花藝村」的溫泉管線已恢復|在木造山景湯屋享受半露天硫磺溫泉

Sep, 2021【苗栗南庄】蓬萊林道Off Road小試|雨後很爛很濕滑|二傳低底盤車勿輕易嘗試

Nov 2024【台北北投】風景如畫的溫泉公園|前山公園散步、紗帽山輕健行,順訪陽明山下的六窟溫泉餐廳|桃園區美食~豚嶼拉麵

Nov 2024【台中西區】精誠壹山海鮮燒肉|在巷弄內的典雅復古風老宅吃燒肉,全程專人代烤

【美國加州】此生必去超美風景!加州一號公路自駕遊~Half Moon Bay、17 Mile Drive、Bixby Greek Bridge、Big Sur、McWay Falls、Elephant Seal Rookery

Oct 21~24, 2023【晚秋の贅沢な山旅 PART②】黒部峽谷♡下之廊下|日本北阿爾卑斯山秘境健行+野營+秘湯溫泉 DAY 1(黒部水壩〜下之廊下〜阿曾原溫泉)

Feb, 2024【台中西區】桃太郎日本料理|隱身巷弄裡的39年老字號無菜單料理|食材新鮮、自然美味

May 2023【台中南屯】地雷店食記|森鐵板燒|用餐體驗差,價格超貴卻豪無價值。小心別踩雷!!!

Sep 2024 晚夏的黑部源流4泊5日山旅 PART ⑤【溪流登攀&溫泉三昧】赤木沢~五郎沢~祖父沢遡行&雲ノ平~高天原~裏銀座縱走(享受高天原溫泉)

Oct 2024【新北新莊】旨醞鐵板料理|38樓高空景觀餐廳+海陸料理|週末家庭聚餐

文章列表

Contact

名稱

以電子郵件傳送 *

訊息 *