From 8f8f75c89ea104ec3bf895386473361347886c87 Mon Sep 17 00:00:00 2001 From: Lukas Oberhuber Date: Thu, 24 Sep 2015 21:37:35 +0100 Subject: [PATCH 1/2] Now won't wait for dependencies that will never install. Before this fix, if for any reason a dependency is not on the install list it will cause a deadlock. This now means the bundle will no longer fail in that instance, which matches the behavior of the sequential installer. It isn't clear why the gem is not making it onto the list however, which appears to be a separate bug. --- lib/bundler/installer/parallel_installer.rb | 9 +++++---- spec/install/parallel/spec_installation_spec.rb | 13 +++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb index 84bdb425fab..af88bca0e29 100644 --- a/lib/bundler/installer/parallel_installer.rb +++ b/lib/bundler/installer/parallel_installer.rb @@ -35,13 +35,14 @@ def ignorable_dependency?(dep) # sure needed dependencies have been installed. def dependencies_installed?(all_specs) installed_specs = all_specs.select(&:installed?).map(&:name) - dependencies.all? {|d| installed_specs.include? d.name } + dependencies(all_specs.map(&:name)).all? {|d| installed_specs.include? d.name } end - # Represents only the non-development dependencies and the ones that - # are itself. - def dependencies + # Represents only the non-development dependencies, the ones that are + # itself and are in the total list. + def dependencies(all_spec_names) @dependencies ||= all_dependencies.reject {|dep| ignorable_dependency? dep } + .select {|dep| all_spec_names.include? dep.name } end # Represents all dependencies diff --git a/spec/install/parallel/spec_installation_spec.rb b/spec/install/parallel/spec_installation_spec.rb index 2d741a15ff5..d32af8524ee 100644 --- a/spec/install/parallel/spec_installation_spec.rb +++ b/spec/install/parallel/spec_installation_spec.rb @@ -57,5 +57,18 @@ def a_spec.name expect(spec.dependencies_installed?(all_specs)).to be_falsey end end + + context "when dependencies that are not on the overall installation list are the only ones not installed" do + it "returns true" do + dependencies = [] + dependencies << instance_double("SpecInstallation", :spec => "alpha", :name => "alpha", :installed? => true, :all_dependencies => [], :type => :production) + all_specs = dependencies + [instance_double("SpecInstallation", :spec => "gamma", :name => "gamma", :installed? => false, :all_dependencies => [], :type => :production)] + # Add dependency which is not in all_specs + dependencies << instance_double("SpecInstallation", :spec => "beta", :name => "beta", :installed? => false, :all_dependencies => [], :type => :production) + spec = ParallelInstaller::SpecInstallation.new(dep) + allow(spec).to receive(:all_dependencies).and_return(dependencies) + expect(spec.dependencies_installed?(all_specs)).to be_truthy + end + end end end From 91f7d3990545a7a09dd0d3529b2a9bb939400553 Mon Sep 17 00:00:00 2001 From: Lukas Oberhuber Date: Sat, 26 Sep 2015 15:21:44 +0100 Subject: [PATCH 2/2] Fix rubocop offense --- lib/bundler/installer/parallel_installer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/bundler/installer/parallel_installer.rb b/lib/bundler/installer/parallel_installer.rb index af88bca0e29..f43b67ec516 100644 --- a/lib/bundler/installer/parallel_installer.rb +++ b/lib/bundler/installer/parallel_installer.rb @@ -41,8 +41,8 @@ def dependencies_installed?(all_specs) # Represents only the non-development dependencies, the ones that are # itself and are in the total list. def dependencies(all_spec_names) - @dependencies ||= all_dependencies.reject {|dep| ignorable_dependency? dep } - .select {|dep| all_spec_names.include? dep.name } + @dependencies ||= all_dependencies.reject {|dep| ignorable_dependency? dep }. + select {|dep| all_spec_names.include? dep.name } end # Represents all dependencies