class Bundler::Injector
def cross_check_for_errors(gemfile_path, original_deps, removed_deps, initial_gemfile)
-
initial_gemfile
(Array
) -- Contents of original Gemfile before any operation. -
removed_deps
(Array
) -- Array of removed dependencies. -
original_deps
(Array
) -- Array of original dependencies. -
gemfile_path
(Pathname
) -- The Gemfile from which to remove dependencies.
def cross_check_for_errors(gemfile_path, original_deps, removed_deps, initial_gemfile) # evaluate the new gemfile to look for any failure cases builder = Dsl.new builder.eval_gemfile(gemfile_path) # record gems which were removed but not requested extra_removed_gems = original_deps - builder.dependencies # if some extra gems were removed then raise error # and revert Gemfile to original unless extra_removed_gems.empty? SharedHelpers.write_to_gemfile(gemfile_path, initial_gemfile.join) raise InvalidOption, "Gems could not be removed. #{extra_removed_gems.join(", ")} would also have been removed. Bundler cannot continue." end # record gems which could not be removed due to some reasons errored_deps = builder.dependencies.select {|d| d.gemfile == gemfile_path } & removed_deps.select {|d| d.gemfile == gemfile_path } show_warning "#{errored_deps.map(&:name).join(", ")} could not be removed." unless errored_deps.empty? # return actual removed dependencies removed_deps - errored_deps end