Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

rails s or bundle exec rails s

In rails 3 does rails s invoke bundler so that you don't need to do bundle exec rails s or is bundle exec required to run rails s in your apps Gemfile environment?

Update It's understood that bundle exec should be used before rake tasks because of different rake versions. See http://railsapps.github.com/installing-rails-3-1.html for more details. This question is about rails scripts, like:

rails s
rails server
rails c
rails console

^Should bundle exec be used before these rails scripts, or is bundler invoked by the rails command?

like image 378
dylanjha Avatar asked Jul 23 '12 17:07

dylanjha


1 Answers

You should get this behavior in Rail >= 3.1 however you need to be careful because you may be using an older version of rake:

It’s good practice to use the command bundle exec rake instead of rake so you’ll use the version of Rake specified in your gemfile (or a dependency specified in the Gemfile.lock file) instead of the default version. For example, instead of rake db:migrate, run bundle exec rake db:migrate.

What You Need to Know: Make sure you are using Rake 0.9.2.2 (or newer) with gem update rake before installing Rails 3.1. And use bundle exec rake instead of rake.

Quoted from: http://railsapps.github.com/installing-rails-3-1.html

It looks like the opposite it true for the rails command:

don’t run bundle exec before rails command, rails already checks the presence of Bundler through the Gemfile and sets up everything according to it without the overhead of bundle exec. rails command is the only exception to the rule.

Quoted from: https://www.wyeworks.com/blog/2011/12/27/bundle-exec-rails-executes-bundler-setup-3-times/

like image 60
barancw Avatar answered Sep 30 '22 14:09

barancw