2012-07-23 40 views
6

In rails 3 does rails s invoke bundler因此您無需執行bundle exec rails s或者bundle exec需要在您的應用程序中運行rails s Gemfile環境?rails s或bundle exec rails

更新 它的瞭解,bundle exec之前應該因爲不同版本的耙耙的任務中使用。有關更多詳情,請參閱http://railsapps.github.com/installing-rails-3-1.html。這個問題是關於軌道的腳本,如:

rails s 
rails server 
rails c 
rails console 

^如果bundle exec這些軌道腳本之前使用,或者是捆綁在鐵軌命令調用?

+0

我總是添加'別名rails ='捆綁exec rails'; alias rake ='bundle exec rake'到我的bashrc。問題解決了。 – meagar 2012-07-23 17:53:40

+0

我不認爲'alias rails ='bundle exec rails'是必要的:請參閱: [http://railsapps.github.com/installing-rails-3-1.html](http://railsapps。 github.com/installing-rails-3-1.html) && [http://yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/](http: //yehudakatz.com/2011/05/30/gem-versioning-and-bundler-doing-it-right/) – dylanjha 2012-07-25 21:49:39

回答

9

你應該在軌得到這個行爲> = 3.1,但是你需要,因爲你可能使用的是舊版本耙要小心:

這是使用命令包EXEC耙,而不是耙好的做法 因此您將使用您的gemfile中指定的Rake版本(或Gemfile.lock文件中指定的 依賴項)而不是默認的 版本。例如,而不是rake db:migrate,運行bundle exec rake db:migrate。

需要了解的內容:在安裝Rails 3.1之前,確保您使用的是帶有gem update rake的Rake 0.9.2.2(或更新版本) 。並使用bundle rar而不是rake來執行rake。

引自:http://railsapps.github.com/installing-rails-3-1.html

看起來相反它真正的軌命令:

沒有運行之前的軌道命令捆綁高管,鐵軌已經檢查 存在捆紮機的通過Gemfile並根據它設置所有內容 ,而不需要bundle exec的開銷。 rails命令是 規則的唯一例外。

引自: - 「!Rails 3中帶有與捆綁支持出爐...捆綁器透明管理你的依賴」 http://blog.wyeworks.com/2011/12/27/bundle-exec-rails-executes-bundler-setup-3-times

+0

我明白'bundle exec'對於rake任務是一個好主意,但是對於rails腳本,軌道服務器「或」軌道控制檯「? – dylanjha 2012-07-23 17:19:13

+0

對不起,我感到困惑......我編輯了這個答案,以反映正確的問題。 – barancw 2012-07-23 17:51:20

+0

感謝您解決這個問題! – dylanjha 2012-07-23 17:58:57

相關問題