summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-12-21 01:10:34 +0100
committerSamuel Giddins <segiddins@segiddins.me>2016-12-26 16:19:38 -0600
commit6ebb5669a89d3b8b0c15fe9f93c2573d51d02925 (patch)
tree1cb8d0fd2b37c4124b74df3cfd40969e81495b58
parentc73b279f919561a3133dd4fea8de59547adfd4e0 (diff)
downloadbundler-6ebb5669a89d3b8b0c15fe9f93c2573d51d02925.tar.gz
[ParallelInstaller] Allow installing with corrupted lockfiles
-rw-r--r--lib/bundler/installer/parallel_installer.rb28
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb
index c973233d99..4ed5a5c9b9 100644
--- a/lib/bundler/installer/parallel_installer.rb
+++ b/lib/bundler/installer/parallel_installer.rb
@@ -47,23 +47,26 @@ module Bundler
# sure needed dependencies have been installed.
def dependencies_installed?(all_specs)
installed_specs = all_specs.select(&:installed?).map(&:name)
- dependencies(all_specs.map(&:name)).all? {|d| installed_specs.include? d.name }
+ dependencies.all? {|d| installed_specs.include? d.name }
end
# Represents only the non-development dependencies, the ones that are
# itself and are in the total list.
- def dependencies(all_spec_names)
+ def dependencies
@dependencies ||= begin
- deps = all_dependencies.reject {|dep| ignorable_dependency? dep }
- missing = deps.reject {|dep| all_spec_names.include? dep.name }
- unless missing.empty?
- raise Bundler::LockfileError, "Your Gemfile.lock is corrupt. The following #{missing.size > 1 ? "gems are" : "gem is"} missing " \
- "from the DEPENDENCIES section: '#{missing.map(&:name).join('\' \'')}'"
- end
- deps
+ all_dependencies.reject {|dep| ignorable_dependency? dep }
end
end
+ def corrupt_lockfile?(all_spec_names)
+ deps = all_dependencies.reject {|dep| ignorable_dependency? dep }
+ missing = deps.reject {|dep| all_spec_names.include? dep.name }
+ return false if missing.empty?
+ Bundler.ui.warn "Your Gemfile.lock is corrupt. The following #{missing.size > 1 ? "gems are" : "gem is"} missing " \
+ "from the DEPENDENCIES section for #{@spec.full_name}: '#{missing.map(&:name).join("', '")}'"
+ true
+ end
+
# Represents all dependencies
def all_dependencies
@spec.dependencies
@@ -92,6 +95,7 @@ module Bundler
# TODO: remove in bundler 2.0
require "bundler/gem_remote_fetcher" if RUBY_VERSION < "1.9"
+ check_for_corrupt_lockfile
enqueue_specs
process_specs until @specs.all?(&:installed?) || @specs.any?(&:failed?)
handle_error if @specs.any?(&:failed?)
@@ -135,6 +139,12 @@ module Bundler
raise Bundler::InstallError, errors.map(&:to_s).join("\n\n")
end
+ def check_for_corrupt_lockfile
+ return unless @specs.any? {|s| s.corrupt_lockfile?(@specs) }
+ Bundler.ui.warn "Using 1 thread to install specs instead of #{@size} due to lockfile corruption" unless @size == 1
+ @size = 1
+ end
+
# Keys in the remains hash represent uninstalled gems specs.
# We enqueue all gem specs that do not have any dependencies.
# Later we call this lambda again to install specs that depended on