EC-Riderをbundlerを使って動かしてみる


bundlerはgemの便利管理ツールです

これを使ってみます。

bundlerのインストール

rvmが入ってるものとします。

# rvm install ruby-1.8.7-p248

最新はruby 1.8.7-p249だけど、下のエラー回避のためp248を使います
Rails 3 betaをrvmとruby 1.8.7でインストールする際のgetc is obsoleteエラーを回避する方法

# rvm use ruby-1.8.7-p248
# gem update --system 
# gem install bundler
# bundle -v
Bundler version 0.9.10

Rails 2.3系でbundlerを使うための設定

RAILS_ROOT以下にGemfileを作成します。
こんな感じです。

Gemfile

source :gemcutter
source "http://gems.github.com"

gem 'rails', '2.3.4'
gem 'mysql'
gem "mongrel", :version => '1.1.5'
gem "locale", :version => '2.0.4'
gem "locale_rails", :version => '2.0.4'
gem "mislav-will_paginate", :version => '2.3.11', :lib => "will_paginate"
gem "kakutani-yaml_waml", :version => '0.3.0', :lib => 'yaml_waml'
gem "fastercsv", :version => '1.4.0' # for jp_address
gem "ar-extensions", :version => '0.9.2'  # for jp_address
gem "rubyzip", :version => '0.9.1', :lib => "zip/zipfilesystem"
gem "git", :version => '1.2.4', :lib => "git"
gem "log4r", :version => '1.1.2'
#gem "aws-s3", :version => '0.5.1', :lib => "aws/s3"
gem "RedCloth", :version => '4.2.2'
gem "roxml", :version => '2.5.3'
gem "selectable_attr", :version => "0.3.7"
gem "selectable_attr_rails", :version => "0.3.9"
gem "state_flow" , :version => "0.2.1"
gem "schema_comments" , :version => "0.1.1"
gem 'magic_userstamp', :version => '0.1.1'
gem 'vestal_versions', :version => '0.8.3'
#gem 'rmagick', :version => '2.12.2'

# development用
group :development do
  gem 'bullet'
end

gem 'rcov'

config/environment.rbの中の『config.gem 〜』は消しときます。

あとは、config/preinitializer.rbというのをつくるのと、config/boot.rbに少し追記します。
下のとおりです。

Rails 2.3

Using Bundler 0.9 with Rails 2.3 requires adding a preinitializer, and making a few changes to boot.rb. The exact changes needed can be found at http://gist.github.com/302406.

http://github.com/carlhuda/bundler

gemをインストール

RAILS_ROOTで

# bundle install
Fetching source index from http://gemcutter.org/
Fetching source index from http://gems.github.com/
Resolving dependencies
Installing RedCloth (4.2.3) from system gems 
Installing actionmailer (2.3.4) from system gems 
Installing actionpack (2.3.4) from system gems 
Installing activerecord (2.3.4) from system gems 
Installing activeresource (2.3.4) from system gems 
Installing activesupport (2.3.4) from system gems 
Installing ar-extensions (0.9.2) from system gems 
Installing bullet (1.7.5) from rubygems repository at http://gemcutter.org/ 
Installing cgi_multipart_eof_fix (2.5.0) from system gems 
Installing daemons (1.0.10) from system gems 
Installing fastercsv (1.5.1) from system gems 
Installing fastthread (1.0.7) from system gems 
Installing gem_plugin (0.2.3) from system gems 
Installing git (1.2.5) from system gems 
Installing kakutani-yaml_waml (0.3.0) from system gems 
Installing locale (2.0.5) from system gems 
Installing locale_rails (2.0.5) from system gems 
Installing log4r (1.1.5) from system gems 
Installing magic_userstamp (0.1.1) from system gems 
Installing mislav-will_paginate (2.3.11) from system gems 
Installing mongrel (1.1.5) from system gems 
Installing nokogiri (1.4.1) from system gems 
Installing rack (1.0.1) from system gems 
Installing rails (2.3.4) from system gems 
Installing rake (0.8.7) from system gems 
Installing roxml (3.1.5) from system gems 
Installing rubyzip (0.9.4) from system gems 
Installing schema_comments (0.1.2) from system gems 
Installing selectable_attr (0.3.11) from system gems 
Installing selectable_attr_rails (0.3.11) from system gems 
Installing state_flow (0.2.1) from system gems 
Installing vestal_versions (1.0.2) from system gems 
Your bundle is complete!

これ速いっすよ!

インストールできたらロックする

# bundle lock 
The bundle is now locked. Use `bundle show` to list the gems in the environment.
# bundle show
Gems included by the bundle:
  * RedCloth (4.2.3)
  * actionmailer (2.3.4)
  * actionpack (2.3.4)
  * activerecord (2.3.4)
  * activeresource (2.3.4)
  * activesupport (2.3.4)
  * ar-extensions (0.9.2)
  * bullet (1.7.5)
  * cgi_multipart_eof_fix (2.5.0)
  * daemons (1.0.10)
  * fastercsv (1.5.1)
  * fastthread (1.0.7)
  * gem_plugin (0.2.3)
  * git (1.2.5)
  * kakutani-yaml_waml (0.3.0)
  * locale (2.0.5)
  * locale_rails (2.0.5)
  * log4r (1.1.5)
  * magic_userstamp (0.1.1)
  * mislav-will_paginate (2.3.11)
  * mongrel (1.1.5)
  * nokogiri (1.4.1)
  * rack (1.0.1)
  * rails (2.3.4)
  * rake (0.8.7)
  * roxml (3.1.5)
  * rubyzip (0.9.4)
  * schema_comments (0.1.2)
  * selectable_attr (0.3.11)
  * selectable_attr_rails (0.3.11)
  * state_flow (0.2.1)
  * vestal_versions (1.0.2)

サーバー起動

# ruby script/server

f:id:tohtas:20100303002850p:image
動きました!