summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorHomu <homu@barosl.com>2016-05-30 14:55:31 +0900
committerHomu <homu@barosl.com>2016-05-30 14:55:31 +0900
commit767323ac8b65a635106210b0c9cdb68b297c47b5 (patch)
treef9476ae77fb13858a689a3eb37be8805639b9c3e /lib
parent074ec03ab135e834f6f4ef0a7c27baf1e49dd2df (diff)
parent1587e0d392ab9861560480ac9c3e143f2153aa79 (diff)
downloadbundler-767323ac8b65a635106210b0c9cdb68b297c47b5.tar.gz
Auto merge of #4606 - allenzhao:handle-yanked, r=RochesterinNYC
Handle yanked gems Close #4344
Diffstat (limited to 'lib')
-rw-r--r--lib/bundler/definition.rb19
1 files changed, 17 insertions, 2 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 294d6567c6..69ecd4fdcc 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -137,8 +137,17 @@ module Bundler
# @return [Bundler::SpecSet]
def specs
@specs ||= begin
- specs = resolve.materialize(Bundler.settings[:cache_all_platforms] ? dependencies : requested_dependencies)
-
+ begin
+ specs = resolve.materialize(Bundler.settings[:cache_all_platforms] ? dependencies : requested_dependencies)
+ rescue GemNotFound => e # Handle yanked gem
+ gem_name, gem_version = extract_gem_info(e)
+ locked_gem = @locked_specs[gem_name].last
+ raise if locked_gem.nil? || locked_gem.version.to_s != gem_version
+ raise GemNotFound, "Your bundle is locked to #{locked_gem}, but that version could not " \
+ "be found in any of the sources listed in your Gemfile. If you haven't changed sources, " \
+ "that means the author of #{locked_gem} has removed it. You'll need to update your bundle " \
+ "to a different version of #{locked_gem} that hasn't been removed in order to install."
+ end
unless specs["bundler"].any?
local = Bundler.settings[:frozen] ? rubygems_index : index
bundler = local.search(Gem::Dependency.new("bundler", VERSION)).last
@@ -690,5 +699,11 @@ module Bundler
end
current == proposed
end
+
+ def extract_gem_info(error)
+ # This method will extract the error message like "Could not find foo-1.2.3 in any of the sources"
+ # to an array. The first element will be the gem name (e.g. foo), the second will be the version number.
+ error.message.scan(/Could not find (\w+)-(\d+(?:\.\d+)+)/).flatten
+ end
end
end