I have a project using cucumber outside of rails. How can I load the gems with the versions specified in my gemfile?
相关问题
- How to specify memcache server to Rack::Session::M
- Why am I getting a “C compiler cannot create execu
- reference to a method?
- ruby 1.9 wrong file encoding on windows
- gem cleanup shows error: Unable to uninstall bundl
相关文章
- Ruby using wrong version of openssl
- Difference between Thread#run and Thread#wakeup?
- how to call a active record named scope with a str
- “No explicit conversion of Symbol into String” for
- Segmentation fault with ruby 2.0.0p247 leading to
- How to detect if an element exists in Watir
- uninitialized constant Mysql2::Client::SECURE_CONN
- ruby - simplify string multiply concatenation
Digging through the Bundler website:
Gemfile
(runbundle init
to create skeletonGemfile
)bundle install
In your app:
Could be worth checking out:
Bundler.io - Using Bundler in Your Appplication
Bundler.io - Bundler.setup and Bundler.require
Are bundle exec and require 'bundler/setup' equivalent?
I just learned about a way to make Bundler automatically require dependencies from a Gemfile. Add this code at the beginning of a Ruby program that has a Gemfile:
With Bundler.require there's no need to explicitly require the gems/libraries enumerated in the Gemfile.
This solution is from http://technotales.wordpress.com/2010/08/22/bundler-without-rails/
To be honest I'm not sure if the require rubygems part is needed either.
Here's the simplest and most straightforward approach:
bundler init
will create the Gemfile for youbundler install
to install the gems.More information can (now) be found at http://bundler.io.
Casper has a pretty good answer (despite some passive aggressiveness) but I think the missing piece for you is
bundle exec
. When you run the$ rails ...
commands on the command line, Rails uses bundler to load those dependencies/gems. Rake, for example, doesn't by default so in order to runrake test
using an older version of cucumber than what is on your system, you have to usebundle exec rake test
. It's a good habit to get into always using$ bundle exec ...
when you're using Bundler — it's explicit, you're always sure you're using the right gems, and it ensures you don't forget to add a dependency to your Gemfile (i.e. you push to another server or another developer and they are having issues because you didn't note the need for something you use but they don't).