Skip to content

Commit

Permalink
Auto merge of rubygems#6188 - bundler:indirect/fix-6072, r=indirect
Browse files Browse the repository at this point in the history
Stop overriding specs during double-checks

This fixes my test-case reproduction of rubygems#6072. I’m pretty sure it’s because
the double-check was overriding the locally installed index specs with
specs fetched from the RubyGems API, causing Bundler to conclude that the
gems aren’t installed, even though they are.

@deivid-rodriguez @y-yagi can you verify that this patch fixes the issues with `inline` that you were seeing?
  • Loading branch information
bundlerbot authored and hsbt committed Dec 11, 2017
1 parent 3a0c85f commit 2875b6e
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 9 deletions.
2 changes: 1 addition & 1 deletion lib/bundler/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ def double_check_for_index(idx, dependency_names)
end

sources.all_sources.each do |source|
source.double_check_for(unmet_dependency_names, :override_dupes)
source.double_check_for(unmet_dependency_names)
end

break if idxcount == idx.size
Expand Down
6 changes: 2 additions & 4 deletions lib/bundler/source/rubygems.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,10 +252,8 @@ def fetchers
end
end

def double_check_for(unmet_dependency_names, override_dupes = false, index = specs)
def double_check_for(unmet_dependency_names)
return unless @allow_remote
raise ArgumentError, "missing index" unless index

return unless api_fetchers.any?

unmet_dependency_names = unmet_dependency_names.call
Expand All @@ -270,7 +268,7 @@ def double_check_for(unmet_dependency_names, override_dupes = false, index = spe

Bundler.ui.debug "Double checking for #{unmet_dependency_names || "all specs (due to the size of the request)"} in #{self}"

fetch_names(api_fetchers, unmet_dependency_names, index, override_dupes)
fetch_names(api_fetchers, unmet_dependency_names, specs, false)
end

def dependency_names_to_double_check
Expand Down
40 changes: 40 additions & 0 deletions spec/realworld/double_check_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# frozen_string_literal: true

RSpec.describe "double checking sources", :realworld => true do
it "finds already-installed gems" do
create_file("rails.gemspec", <<-RUBY)
Gem::Specification.new do |s|
s.name = "rails"
s.version = "5.1.4"
s.summary = ""
s.description = ""
s.author = ""
s.add_dependency "actionpack", "5.1.4"
end
RUBY

create_file("actionpack.gemspec", <<-RUBY)
Gem::Specification.new do |s|
s.name = "actionpack"
s.version = "5.1.4"
s.summary = ""
s.description = ""
s.author = ""
s.add_dependency "rack", "~> 2.0.0"
end
RUBY

cmd = <<-RUBY
require "bundler"
require #{File.expand_path("../../support/artifice/vcr.rb", __FILE__).dump}
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails", path: "."
end
RUBY

ruby! cmd
ruby! cmd
end
end
4 changes: 0 additions & 4 deletions spec/runtime/inline_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ def script(code, options = {})
build_lib "eight", "1.0.0" do |s|
s.write "lib/eight.rb", "puts 'eight'"
end

build_lib "four", "1.0.0" do |s|
s.write "lib/four.rb", "puts 'four'"
end
end

it "requires the gems" do
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
> GET /gems/rack-2.0.1.gem
> accept-encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3
> accept: */*
> user-agent: Ruby
> connection: keep-alive
> keep-alive: 30
> host: rubygems.org
Binary file not shown.

0 comments on commit 2875b6e

Please sign in to comment.