summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-06-23 17:32:09 -0500
committerSamuel Giddins <segiddins@segiddins.me>2017-06-23 23:29:09 -0500
commit0f336c7d311f2471e7191db05ddc0f9c278829a5 (patch)
treeb4f9b6866f7da1b3c91088bd762f55d04daa6b42
parent6b40a8a22bfb3f04e677a3de4d5b9329c689d2c2 (diff)
downloadbundler-0f336c7d311f2471e7191db05ddc0f9c278829a5.tar.gz
Always serve the Bundler gemspec from the metadata source
-rw-r--r--lib/bundler/definition.rb16
-rw-r--r--lib/bundler/source/metadata.rb24
-rw-r--r--lib/bundler/source/rubygems.rb32
3 files changed, 32 insertions, 40 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index bcae470569..dc8bdc7bad 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -167,8 +167,8 @@ module Bundler
"to a different version of #{locked_gem} that hasn't been removed in order to install."
end
unless specs["bundler"].any?
- bundler = rubygems_index.search(Gem::Dependency.new("bundler", VERSION)).last
- specs["bundler"] = bundler if bundler
+ bundler = sources.metadata_source.specs.search(Gem::Dependency.new("bundler", VERSION)).last
+ specs["bundler"] = bundler
end
specs
@@ -286,16 +286,6 @@ module Bundler
end
private :double_check_for_index
- # used when frozen is enabled so we can find the bundler
- # spec, even if (say) a git gem is not checked out.
- def rubygems_index
- @rubygems_index ||= Index.build do |idx|
- sources.rubygems_sources.each do |rubygems|
- idx.add_source rubygems.specs
- end
- end
- end
-
def has_rubygems_remotes?
sources.rubygems_sources.any? {|s| s.remotes.any? }
end
@@ -935,7 +925,7 @@ module Bundler
# specs will be available later when the resolver knows where to
# look for that gemspec (or its dependencies)
default = sources.default_source
- source_requirements = { :default => default }
+ source_requirements = { :default => default, "bundler" => sources.metadata_source }
default = nil unless Bundler.feature_flag.lockfile_uses_separate_rubygems_sources?
dependencies.each do |dep|
next unless source = dep.source || default
diff --git a/lib/bundler/source/metadata.rb b/lib/bundler/source/metadata.rb
index 173c897998..63d16365c5 100644
--- a/lib/bundler/source/metadata.rb
+++ b/lib/bundler/source/metadata.rb
@@ -7,6 +7,21 @@ module Bundler
@specs ||= Index.build do |idx|
idx << Gem::Specification.new("ruby\0", RubyVersion.system.to_gem_version_with_patchlevel)
idx << Gem::Specification.new("rubygems\0", Gem::VERSION)
+
+ idx << Gem::Specification.new do |s|
+ s.name = "bundler"
+ s.version = VERSION
+ s.platform = Gem::Platform::RUBY
+ s.source = self
+ s.authors = ["bundler team"]
+ # can't point to the actual gemspec or else the require paths will be wrong
+ s.loaded_from = File.expand_path("..", __FILE__)
+ end
+ if loaded_spec = nil && Bundler.rubygems.loaded_specs("bundler")
+ idx << loaded_spec # this has to come after the fake gemspec, to override it
+ elsif local_spec = Bundler.rubygems.find_name("bundler").find {|s| s.version.to_s == VERSION }
+ idx << local_spec
+ end
end
end
@@ -14,6 +29,15 @@ module Bundler
def remote!; end
+ def options
+ {}
+ end
+
+ def install(spec, opts)
+ Bundler.ui.info "Using #{version_message(spec)}"
+ nil
+ end
+
def to_s
"the local ruby installation"
end
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 4d87ca7249..98c8fdad3b 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -105,7 +105,7 @@ module Bundler
end
end
- if installed?(spec) && (!force || spec.name.eql?("bundler"))
+ if installed?(spec) && !force
Bundler.ui.info "Using #{version_message(spec)}"
return nil # no post-install message
end
@@ -305,14 +305,9 @@ module Bundler
end
def installed_specs
- @installed_specs ||= begin
- idx = Index.new
- have_bundler = false
+ @installed_specs ||= Index.build do |idx|
Bundler.rubygems.all_specs.reverse_each do |spec|
- if spec.name == "bundler"
- next unless spec.version.to_s == VERSION
- have_bundler = true
- end
+ next if spec.name == "bundler"
spec.source = self
if Bundler.rubygems.spec_missing_extensions?(spec, false)
Bundler.ui.debug "Source #{self} is ignoring #{spec} because it is missing extensions"
@@ -320,23 +315,6 @@ module Bundler
end
idx << spec
end
-
- # Always have bundler locally
- unless have_bundler
- # We're running bundler directly from the source
- # so, let's create a fake gemspec for it (it's a path)
- # gemspec
- bundler = Gem::Specification.new do |s|
- s.name = "bundler"
- s.version = VERSION
- s.platform = Gem::Platform::RUBY
- s.source = self
- s.authors = ["bundler team"]
- s.loaded_from = File.expand_path("..", __FILE__)
- end
- idx << bundler
- end
- idx
end
end
@@ -354,9 +332,9 @@ module Bundler
end
idx << s
end
- end
- idx
+ idx
+ end
end
def api_fetchers