summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHemant Kumar <gethemant@gmail.com>2014-01-10 11:27:14 +0530
committerHemant Kumar <gethemant@gmail.com>2014-01-10 11:27:14 +0530
commitb88481eec885cc05c952774d05ae036048fc8eef (patch)
tree3745db7013c62dfe5c6787be0c0eb2ae0720480c
parent706c9d34ebd7750c38db5e1fab9e5c7fee2151c4 (diff)
downloadbundler-2813-fix-self-dependency-bug.tar.gz
Fix self dependency of gems while installing parallely.2813-fix-self-dependency-bug
Thanks to @schneems for reporting and fixing the problem.We now detect if gem has a dependency with same name and proceed with installation if that is the case and that is the only dependency left.
-rw-r--r--lib/bundler/installer.rb18
-rw-r--r--spec/realworld/parallel_install_spec.rb13
2 files changed, 28 insertions, 3 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index b6a2a06a73..16b2aef911 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -278,7 +278,6 @@ module Bundler
name2spec[spec.name] = spec
remains[spec.name] = true
end
-
worker_pool = ParallelWorkers.worker_pool size, lambda { |name, worker|
spec = name2spec[name]
message = install_gem_from_spec spec, standalone, worker
@@ -291,7 +290,6 @@ module Bundler
enqueued[spec.name] = true
end
end
-
until remains.empty?
message = worker_pool.deq
remains.delete message[:name]
@@ -301,7 +299,7 @@ module Bundler
remains.keys.each do |name|
next if enqueued[name]
spec = name2spec[name]
- deps = spec.dependencies.select { |dep| remains[dep.name] and dep.type != :development }
+ deps = installable_dependencies(spec, name, remains)
if deps.empty?
worker_pool.enq name
enqueued[name] = true
@@ -312,5 +310,19 @@ module Bundler
ensure
worker_pool && worker_pool.stop
end
+
+ def installable_dependencies(spec, spec_name, remains)
+ spec.dependencies.select do |dep|
+ check_if_requires_installing?(remains, spec_name, dep)
+ end
+ end
+
+ def check_if_requires_installing?(remains, parent_spec_name, dep)
+ return false if dep.type == :development
+
+ return false if dep.name == parent_spec_name && remains[dep.name]
+
+ remains[dep.name]
+ end
end
end
diff --git a/spec/realworld/parallel_install_spec.rb b/spec/realworld/parallel_install_spec.rb
index ca92ca016b..5ee514858a 100644
--- a/spec/realworld/parallel_install_spec.rb
+++ b/spec/realworld/parallel_install_spec.rb
@@ -20,4 +20,17 @@ describe "installing dependencies parallely", :realworld => true do
bundle "config jobs"
expect(out).to match(/: "2"/)
end
+
+ it 'installs even with circular dependency' do
+ gemfile <<-G
+ source 'https://rubygems.org'
+ gem 'mongoid_auto_increment', "0.1.1"
+ G
+
+ bundle :install, :jobs => 2, :env => {"DEBUG" => "1"}
+ (0..1).each {|i| expect(out).to include("#{i}: ") }
+
+ bundle "show mongoid_auto_increment"
+ expect(out).to match(/mongoid_auto_increment/)
+ end
end