What are "bundler / setup" and "Bundler.require" for?

There boot.rbis a line in the Rails application :

require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])

There application.rbis another line in:

Bundler.require(:default, Rails.env)

Could you briefly explain what Rails / Bundler does in require 'bundler/setup'and 'Bundler.require'?

Is this a statement that the Bundler is required in bundler/setup, and all the gems of Gemfileare required in Bundler.require?

+4
source share
1 answer

What it does require 'bundler/setup'is that Rails automatically detects the Gemfile and then adds all the gems defined in it to the Ruby boot path.

Bundler.require(:default, Rails.env) Gemfile Rails. , , Rails , .

, !

+6

All Articles