Bundlerã¯ãrubygemsã®ã©ããã¼ã§ããRails3ã®gem管çã«æ¡ç¨ããã¦ãã¾ãã
Bundlerã使ããã¨ã§ã
- ãã®gemãæå ã«ã¯ã¤ã³ã¹ãã¼ã«ããã¦ããã®ã«ãæ¬çªç°å¢ã«ã¤ã³ã¹ãã¼ã«ããã¦ãªãï¼
- éçºç°å¢ã«gemãå ¥ãã¾ãã£ãããããã¸ã§ã¯ãã«ã©ã®gemãå¿ è¦ãªã®ãåãããªããªã£ãï¼
ã¿ãããªåé¡ã解決ã§ãã¾ãã
詳ããã¯公式サイトãã覧ãã ããã
ä»æ¥ã¯ãããªBundlerã«ã¤ãã¦è²ã åãã£ã¦ããã®ã§ãTipsãããã¤ãç´¹ä»ãããã¨æãã¾ãã
åæç¥è
ãã®è¨äºã¯ããã®ã¸ããç解åºæ¥ã¦ãããã¨ãåæã§ãã
Bundlerã¯1.0系以éã使ãã
2010/07/03ç¾å¨ãbundlerã«ã¯0.9ç³»(stable)ã¨1.0ç³»(beta)ãããã¾ãã
ã¤ã³ã¿ãã§ã¼ã¹ãæåãå°ã
å¤ãã£ã¦ããã®ã§ãç¹ã«çç±ããªããã°1.0ç³»ããããããã¾ãã
ã¤ã³ã¹ãã¼ã«æã« --pre ãªãã·ã§ã³ãä»ãããã¨ã§ãææ°çãã¤ã³ã¹ãã¼ã«ã§ãã¾ããï¼å·çæç¹ã§ã¯1.0.0.beta2ï¼
$ gem install bundler --pre
ã¡ãªã¿ã«ãã®è¨äºã¯ãbundler-1.0.0.beta2ãåæã«æ¸ããã¦ãã¾ãã
Bundlerã§å ¥ããgemãã·ã¹ãã ã®gemã¨åé¢ãã¦ãããã
$ gem list
ã¨ãã£ã¦åºã¦ããgemã¯ãããã©ã«ãã§ã¯ $GEM_HOME ã¨ããç°å¢å¤æ°ã®æãå ´æã«ã¤ã³ã¹ãã¼ã«ããã¦ãã¾ã*1ãåã®å ´åã¯ã
$ echo $GEM_HOME /home/mirakui/.rvm/gems/ruby-1.9.2-head
ã§ããã
é常ã bundle install ã³ãã³ãã使ãã¨ã Gemfile ã«æ¸ãããgem㯠$GEM_HOME 以ä¸ã«ã¤ã³ã¹ãã¼ã«ããã¾ããã¤ã¾ããã·ã¹ãã ã®gemã¨ãã£ã¡ãã«ãªã£ã¦ãã¾ãã¾ãã
ããã¸ã§ã¯ãã«å¿
è¦ãªgemã¯ã$GEM_HOMEã§ã¯ãªãããã®ããã¸ã§ã¯ãã®ãã£ã¬ã¯ããªã«å
¥ãã¦ããããã§ããã*2ããã®å ´åã¯ã以ä¸ã®ããã«ãã¾ãã
$ bundle install [DIR]
ããã§ãgemã¯DIR以ä¸ã«å±éãããã®ã§ã$GEM_HOMEã¯æ±æããã¾ãããã¡ãªã¿ã«ãããããã¯å ¬å¼ãµã¤ãã«ãããéã
$ bundle install vendor/bundle
ã§ãã
ãªãããã®ããã«ãã£ã¬ã¯ããªãè¨å®ã㦠bundle install ããã¨ã次å以éã¯ãã£ã¬ã¯ããªãæå®ããªãã¦ããã®ãã£ã¬ã¯ããªã使ããã¾ãããã®è¨å®ã¯Bundlerãçæãã .bundler/config ã¨ãããã¡ã¤ã«ã«æ¸ãåºããã¦ãã¾ãã
$ cat .bundle/config --- BUNDLE_DISABLE_SHARED_GEMS: "1" BUNDLE_WITHOUT: "" BUNDLE_PATH: vendor/bundle
BUNDLE_PATHã®é¨åãããã§ããBundlerã¯BUNDLE_PATH以ä¸ãgemã¨ãã¦èªã¿æ¸ããã¾ãããã®.bundle/configãã¡ã¤ã«ãããå ´åã¯ã
$ bundle install
ã¨æã¤ã ãã§ã.bundle/configã«æ¸ããã¦ãããªãã·ã§ã³ãæå®ããã®ã¨åãå¹æãå¾ããã¾ããããã bundle install ã¯
$ bundle
ã¨çç¥ãããã¨ãã§ãã¾ãã
ã·ã¹ãã ã«åãgemãå ¥ã£ã¦ããããã¡ãã使ããã
ãã¨ãã°ã $GEM_HOME ã« nokogiri ãå
¥ã£ã¦ããå ´åãGemfileã«nokogiriãæå®ãã¦bundle installãã¦ããã¤ã³ã¹ãã¼ã«ã¯ã¹ãããããã¦ã $GEM_HOME ã®nokogiriã使ããã¾ãã
ãããåé¿ããå ´åã¯ã--disable-shared-gems ãªãã·ã§ã³ãã¤ãã¾ãããã
$ bundle install vendor/bundle --disable-shared-gems
公式サイトã«ãæ¸ãã¦ãããã®ã³ãã³ãããæçµçãªãªã¹ã¹ã¡ã®bundle installã§ãã
Bundlerãå ¥ããgemã使ã£ã¦rubyãå®è¡ããã
以ä¸ã®ããã«bundle execã使ãã¨ãBUNDLE_PATH以ä¸ã®gemã使ã£ã¦ãã¹ã¯ãªãããå®è¡ã§ãã¾ãã
$ bundle exec ruby your-script.rb
irbã®å ´åã¯ã以ä¸ã®ãããªã³ãã³ããç¨æããã¦ãã¾ãã
$ bundle console
ããã¯ã bundle exec irb ã¨åçã§ãï¼å¤åï¼ã
ã³ã³ãã¤ã«ãªãã·ã§ã³ã®æå®ãå¿ è¦ãªgemãbundlerã§å ¥ããã
æ®å¿µãªãã1.0.0.beta2ç¾å¨ãGemfileã«ãgemã®ã³ã³ãã¤ã«ãªãã·ã§ã³ãæå®ããæ©è½ã¯ä»ãã¦ããªãããã§ãã
ãªã®ã§ã以ä¸ã®ãããªæé ã§ä»£æ¿ãã¾ãã以ä¸ã®ä¾ã¯ã「--with-ruby-include」を指定してruby-debug19をビルドããæ¹æ³ã§ãã
$ cat Gemfile : gem 'ruby-debug19' $ bundle install vendor/bundle --disable-shared # ruby-debug19ã®ã³ã³ãã¤ã«ã¨ã©ã¼ $ env GEM_HOME=`pwd`/vendor/bundle gem install ruby-debug19 -- --with-ruby-include=$rvm_ruby_src_path # bundle install ã®åã«vendor/bundleã«gemãå ¥ãã¦ãã $ bundle install # æå
cronããrvmã¨bundlerã使ããã
cronã§rubyã¹ã¯ãªãããå®è¡ãããç°å¢å¤æ°ãééã£ã¦ã¦ãã¾ãå®è¡ã§ããªãã£ããã¨ããã®ã¯èª°ãããéãéã ã¨æãã¾ãã
RVMã使ã£ã¦ããã°ã$HOME/.rvm/scripts/rvm ãå®è¡ï¼sourceï¼ãããã¨ã§ãããå
·åã«ç°å¢å¤æ°ãèªã¿è¾¼ãã§ããã¾ãã
* * * * * source $HOME/.rvm/scripts/rvm; rvm your-ruby-version; cd /path-to-project/; bundle exec ruby your-script.rb
æå¾ã«
bundlerã«ã¤ãã¦ãã¾ã åãã£ã¦ãªããã¨ãããã¤ãããã®ã§ãããããåãã£ããTipsãã®2ãæ¸ãããã¨æãã¾ãã
- Bundler1.0ãããbundle installæã«èªåçã«bundle lockãããããã«ãªã£ãããbundle installã®ãã³ã«æ¯åGemfile.lockãæ´æ°ããã¦ãã¾ãã®ã§å®è³ªçã«lockãã§ããªããªã£ã¦ããããªæ°ããã
- åæ§ã«ãbundle install ã§Gemfile.lockããã£ã¦ãgemãã¢ãããã¼ãããã¦ãã¾ãã®ã§ãbundle install 㨠bundle update ã®å·®ããªããªã£ã¦ãæ°ããã
- åæ§ã«ãbundle installã§æ¯åsourceããã§ãããã¦æ´æ°ã®æç¡ã調ã¹ã¦ãã®ã§ãbundle packageã§ä½ãããvendor/cache以ä¸ã®gemãããã¾ãæå³ãªããªã£ã¦ãæ°ããã