參考了很多 Mac Ruby 更新的文章,大部分的人還是傾向直接用 MacPorts 更新,趁著更新的同時也記錄一下更新的筆記
首先如果你的 Mac 還沒裝 MacPorts 先到官網下載 MacPorts-1.9.2.pkg
安裝完後進行更新$sudo port -d selfupdate
MacPorts command:
port -d selfupdate #=> 升級 macport
port install xxx #=> 安裝 xxx 軟體
port upgrade outdated #=> 升級所有軟體
port installed #=> 列出已經安裝軟體
port search xxx #=> 列出與 xxx 條件相符的軟體
接下來,安裝 ruby1.9
(註. 一般來說用 MacPorts 安裝 ruby 要指定版本,如果你只下 “port install ruby” 指令,那安裝之後的版本是 1.8.7…)$sudo port install ruby1.9
安裝之後的 path /opt/local/bin
ruby1.9 有幾個檔案需要更動連結
=> erb1.9
=> gem1.9
=> irb1.9
=> rake1.9
=> rdoc1.9
=> ri1.9
=> ruby1.9
=> testrb1.9
移除 1.8 path /usr/bin$sudo rm /usr/bin/erb
$sudo rm /usr/bin/gem
$sudo rm /usr/bin/irb
$sudo rm /usr/bin/rake
$sudo rm /usr/bin/rdoc
$sudo rm /usr/bin/ri
$sudo rm /usr/bin/ruby
$sudo rm /usr/bin/testrb
將 link 更新為 1.9$sudo ln -s /opt/local/bin/erb1.9 /usr/bin/erb
$sudo ln -s /opt/local/bin/gem1.9 /usr/bin/gem
$sudo ln -s /opt/local/bin/irb1.9 /usr/bin/irb
$sudo ln -s /opt/local/bin/rake1.9 /usr/bin/rake
$sudo ln -s /opt/local/bin/rdoc1.9 /usr/bin/rdoc
$sudo ln -s /opt/local/bin/ri1.9 /usr/bin/ri
$sudo ln -s /opt/local/bin/ruby1.9 /usr/bin/ruby
$sudo ln -s /opt/local/bin/testrb1.9 /usr/bin/testrb
下一步,如果你已經在舊版的 gem 裝很了很 library 請先備份清單$sudo gem list
將顯示的清單貼到文字編輯器中就行了
在 gem1.9 重新安裝之前的清單即可
Rails 的部份也可用 gem1.9 重新安裝$sudo gem1.9 rails
原 Mac ruby1.8.7 路徑
ri -> ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ri
ruby -> ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby
rdoc -> ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/rdoc
gem -> ../../System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem
irb -> ../../System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/irb
# If you want to revert to default 1.8
ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/erb /usr/bin/erb
ln -s /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/gem /usr/bin/gem
ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/irb /usr/bin/irb
ln -s /usr/bin/rake.1.8 /usr/bin/rake
ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/rdoc /usr/bin/rdoc
ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ri /usr/bin/ri
ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby /usr/bin/ruby
ln -s /System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/testrb /usr/bin/testrb
Reference:
- http://blog.jeffean.net/2010/08/macport.html
- Ruby1.8.7 與 Mac OSX 的地雷
- Spree 0.10.2 discriminates Ruby10 :(
- Running a Ruby on Rails Application on OSX with Ruby1.9
- Install Ruby on Rails using MacPorts
- MultiRuby The MacPorts Way. Testing Your Rails Apps With Ruby1.9
同步更新於 Halo!
留言列表