There are different ways to run Rails:
rails
bin/rails
bundle exec rails
Which one should you use?
rails
is the command installed by Bundler. It's located where Bundler installs the railties
gem, within the bindir
subfolder "exe"
, and is the exe/rails
command. When you have installed Rails but and need to set up a new Rails app with the rails new
command, you'll need to use the rails
command.
bin/rails
is the command installed by Rails when you create a new app. It's a binstub generated from a Rails template which produces a file called bin/rails
within your Rails app directory. The command line examples in the Rails Guides use bin/rails
. And it is recommended to use bin/rails
over rails
:
Beginning in Rails 4, Rails ships with a
rails
binstub at ./bin/rails that
should be used instead of the Bundler-generatedrails
binstub.
bundle exec rails
executes the rails
command in a way where all gems specified in the Gemfile
available to require
. Using bin/rails
also does this and loads the gems when config/boot.rb
requires bundler/setup
.
To create a new app use rails
. From that point on, use bin/rails
.