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

Jan 2025【日本東北】溫泉三昧之旅② 在大雪飄落的雪國,追尋秘湯之宿與極上美食(仙台~品嚐極上米澤牛&奧羽的百年藥湯-鎌先溫泉)

Jan 2025【苗栗泰安】泰安警光山莊泡湯&彰化CP值極高的日本料理|沐藏料理所X海龍王|彰化板前料理 ♨️🍁🥢🍲

Jan 2025【台中北屯】大坑步道|頭嵙山健行|大坑5-1號步道上,大坑5號步道下(小百岳No.41)

Jan 2025【苗栗三義】富貴牡丹(三義館)人文藝術餐廳|預約制|在美術館裡吃無菜單料理

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

Jan 2025【日本東北】溫泉三昧之旅⑤ 在大雪飄落的雪國,追尋秘湯之宿與極上美食(福島~被時光遺忘下的江戶原風景,日本三大茅葺聚落大內宿)

2019.10.9~13【令和元年の紅葉の山旅へ PART①】秋の贅沢、黒部川の源流へ北アルプス深部を縦走5日間!Day0、Day1(前泊、折立~藥師岳山莊)

【2025.1.17 更新】有關 AI Agent、Gemini 2.0 與 Multimodal Live API 的一些隨想和實作

Feb 2023【台中和平】裡冷林道Off Road單車野營~順登谷關七雄之首八仙山!單車+野營+登山,三個願望一次滿足

文章列表

Contact

名稱

以電子郵件傳送 *

訊息 *