Method: Bundler::Installer#run

Defined in:
lib/bundler/installer.rb

#run(options) ⇒ Object

Runs the install procedures for a specific Gemfile.

Firstly, this method will check to see if ‘Bundler.bundle_path` exists and if not then Bundler will create the directory. This is usually the same location as RubyGems which typically is the `~/.gem` directory unless other specified.

Secondly, it checks if Bundler has been configured to be “frozen”. Frozen ensures that the Gemfile and the Gemfile.lock file are matching. This stops a situation where a developer may update the Gemfile but may not run ‘bundle install`, which leads to the Gemfile.lock file not being correctly updated. If this file is not correctly updated then any other developer running `bundle install` will potentially not install the correct gems.

Thirdly, Bundler checks if there are any dependencies specified in the Gemfile. If there are no dependencies specified then Bundler returns a warning message stating so and this method returns.

Fourthly, Bundler checks if the Gemfile.lock exists, and if so then proceeds to set up a definition based on the Gemfile and the Gemfile.lock. During this step Bundler will also download information about any new gems that are not in the Gemfile.lock and resolve any dependencies if needed.

Fifthly, Bundler resolves the dependencies either through a cache of gems or by remote. This then leads into the gems being installed, along with stubs for their executables, but only if the –binstubs option has been passed or Bundler.options has been set earlier.

Sixthly, a new Gemfile.lock is created from the installed gems to ensure that the next time that a user runs ‘bundle install` they will receive any updates from this process.

Finally, if the user has specified the standalone flag, Bundler will generate the needed require paths and save them in a ‘setup.rb` file. See `bundle standalone –help` for more information.

[View source]

68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/bundler/installer.rb', line 68

def run(options)
  Bundler.create_bundle_path

  ProcessLock.lock do
    @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])

    if @definition.dependencies.empty?
      Bundler.ui.warn "The Gemfile specifies no dependencies"
      lock
      return
    end

    if @definition.setup_domain!(options)
      ensure_specs_are_compatible!
      load_plugins
    end
    install(options)

    Gem::Specification.reset # invalidate gem specification cache so that installed gems are immediately available

    lock
    Standalone.new(options[:standalone], @definition).generate if options[:standalone]
  end
end