Key pointers from the article
- When running an executable, ALWAYS use
bundle exec [command]
. Quoting from the bundler documentation: In some cases, running executables without bundle exec may work, if the executable happens to be installed in your system and does not pull in any gems that conflict with your bundle. However, this is unreliable and is the source of considerable pain. Even if it looks like it works, it may not work in the future or on another machine. - When you run an executable from the command line without bundle exec, this wrapper invokes Rubygems, which then uses the normal Rubygems activation mechanism to invoke the gem’s executable. This has changed in the past several months, but Rubygems will invoke the latest version of the gem installed in your system, even if your
Gemfile.lock
specifies a different version. In addition, it will activate the latest (compatible) installed version of dependencies of that gem, even if a different version is specified in yourGemfile.lock
. - The only exception to the above rules is the
rails
executable. As of Rails 3.0, the executable simply looks for ascript/rails
file, andexec
s that file. The generatedscript/rails
loads the local boot environment, which invokes bundler immediately.
This explains when the Gemfile specifies Rails gem of "3.0.5", and the system Rails gem is "3.1.0", typing the command "rails -v" inside and outside the application root directory gives different version value
Inside application root directory:
06:12 PM ~/Development/rails_projects/app_0515 $ rails -v
rails Rails 3.0.5
Outside application root directory:
06:21 PM ~/Development/rails_projects $ rails -v
Rails 3.1.0
No comments:
Post a Comment