Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Bundler: What does :require => nil in Gemfile mean?

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?

like image 641
SteveO7 Avatar asked Aug 30 '12 15:08

SteveO7


People also ask

What is require in gem file?

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.

What does require false in Gemfile mean?

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 .

What does require bundler setup do?

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.


2 Answers

Yes, nil and false behave the same here: it makes Bundler not require the specified gem.

like image 79
Veraticus Avatar answered Sep 24 '22 10:09

Veraticus


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.).

like image 24
alup Avatar answered Sep 20 '22 10:09

alup