Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #2813: Ignore self dependency #2817

Merged
merged 2 commits into from Jan 10, 2014
Merged
Changes from all commits
Commits
File filter...
Filter file types
Jump to…
Jump to file or symbol
Failed to load files and symbols.

Always

Just for now

@@ -284,33 +284,45 @@ def install_in_parallel(size, standalone)
message = install_gem_from_spec spec, standalone, worker
{ :name => spec.name, :post_install => message }
}
specs.each do |spec|
deps = spec.dependencies.select { |dep| dep.type != :development }
if deps.empty?
worker_pool.enq spec.name
enqueued[spec.name] = true

# 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
# previously installed specifications. We continue until all specs
# are installed.
enqueue_remaining_specs = lambda do
remains.keys.each do |name|
next if enqueued[name]
spec = name2spec[name]
if ready_to_install?(spec, remains)
worker_pool.enq name
enqueued[name] = true
end
end
end
enqueue_remaining_specs.call

until remains.empty?
message = worker_pool.deq
remains.delete message[:name]
if message[:post_install]
Installer.post_install_messages[message[:name]] = message[:post_install]
end
remains.keys.each do |name|
next if enqueued[name]
spec = name2spec[name]
deps = spec.dependencies.select { |dep| remains[dep.name] and dep.type != :development }
if deps.empty?
worker_pool.enq name
enqueued[name] = true
end
end
enqueue_remaining_specs.call
end
message
ensure
worker_pool && worker_pool.stop
end

# We only want to install a gem spec if all its dependencies are met.
# If the dependency is no longer in the `remains` hash then it has been met.
# If a dependency is only development or is self referential it can be ignored.
def ready_to_install?(spec, remains)
spec.dependencies.none? do |dep|
next if dep.type == :development || dep.name == spec.name
remains[dep.name]
end
end
end
end
@@ -12,12 +12,25 @@
(0..1).each {|i| expect(out).to include("#{i}: ") }

bundle "show activesupport"
expect(out).to match(/activesupport/)
expect(out).to match(%r{gems/activesupport})

bundle "show faker"
expect(out).to match(/faker/)

bundle "config jobs"
expect(out).to match(/: "2"/)
end

it "installs even with circular dependency", :realworld => true 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(%r{gems/mongoid_auto_increment})
end
end
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.