What does the nil mean in this gemfile entry?
gem "hub", ">= 1.10.2", :require => nil
I found this question and answer for false;
Bundler: What does :require => false in a Gemfile mean?
In this context, does nil behave the same as false?
Gemfiles require at least one gem source, in the form of the URL for a RubyGems server. Generate a Gemfile with the default rubygems.org source by running bundle init . If you can, use https so your connection to the rubygems.org server will be verified with SSL.
You use :require => false when you want the gem to be installed but not "required". So in the example you gave: gem 'whenever', :require => false when someone runs bundle install the whenever gem would be installed as with gem install whenever .
Bundler. setup only sets up the load paths so that you can require your dependencies when and wherever you like. Bundler. require sets up the load paths and automatically requires every dependency, saving you from having to manually require each one.
Yes, nil
and false
behave the same here: it makes Bundler not require the specified gem.
Require nil
or false
means that bundler will not load (require
) the specific gems. However, they will be in the $:
load paths, so you can require them explicitly any time you want to use them. It is a good practice to use this, for gems that are only needed in special cases (e.g. external scripts, rake tasks etc.).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With