summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Wen <jrw2175@columbia.edu>2016-03-31 00:28:15 -0400
committerJames Wen <jrw2175@columbia.edu>2016-03-31 15:04:39 -0400
commite110c4562cfb54d1f88d2a6d1c4d66b1fe9d49e5 (patch)
tree9351a4f586963d9892dc93eb07217d08250d4001
parent3a09448d8b060f2688dbc73bfa1eb08e1bd126f3 (diff)
downloadbundler-e110c4562cfb54d1f88d2a6d1c4d66b1fe9d49e5.tar.gz
Suggest usage of `--full-index` flag in case of Dependency API failure
- Closes #4384 Signed-off-by: James Wen <jrw2175@columbia.edu>
-rw-r--r--lib/bundler/fetcher/dependency.rb6
-rw-r--r--spec/bundler/fetcher/dependency_spec.rb36
2 files changed, 26 insertions, 16 deletions
diff --git a/lib/bundler/fetcher/dependency.rb b/lib/bundler/fetcher/dependency.rb
index 8b41fe9999..0e67375de8 100644
--- a/lib/bundler/fetcher/dependency.rb
+++ b/lib/bundler/fetcher/dependency.rb
@@ -33,10 +33,14 @@ module Bundler
returned_gems = spec_list.map(&:first).uniq
specs(deps_list, full_dependency_list + returned_gems, spec_list + last_spec_list)
- rescue HTTPError, MarshalError, GemspecError
+ rescue MarshalError
Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
Bundler.ui.debug "could not fetch from the dependency API, trying the full index"
nil
+ rescue HTTPError, GemspecError
+ Bundler.ui.info "" unless Bundler.ui.debug? # new line now that the dots are over
+ Bundler.ui.debug "could not fetch from the dependency API\nit's suggested to retry using the full index via `bundle install --full-index`"
+ nil
end
def dependency_specs(gem_names)
diff --git a/spec/bundler/fetcher/dependency_spec.rb b/spec/bundler/fetcher/dependency_spec.rb
index fd0d5ed9d3..b11bcdcd79 100644
--- a/spec/bundler/fetcher/dependency_spec.rb
+++ b/spec/bundler/fetcher/dependency_spec.rb
@@ -79,6 +79,9 @@ describe Bundler::Fetcher::Dependency do
allow(bundler_retry).to receive(:attempts) {|&block| block.call }
allow(subject).to receive(:log_specs) {}
allow(subject).to receive(:remote_uri).and_return(remote_uri)
+ allow(Bundler).to receive_message_chain(:ui, :debug?)
+ allow(Bundler).to receive_message_chain(:ui, :info)
+ allow(Bundler).to receive_message_chain(:ui, :debug)
end
context "when there are given gem names that are not in the full dependency list" do
@@ -139,21 +142,10 @@ describe Bundler::Fetcher::Dependency do
end
shared_examples_for "the error is properly handled" do
- before do
- allow(Bundler).to receive_message_chain(:ui, :debug?)
- allow(Bundler).to receive_message_chain(:ui, :info)
- allow(Bundler).to receive_message_chain(:ui, :debug)
- end
-
it "should return nil" do
expect(subject.specs(gem_names, full_dependency_list, last_spec_list)).to be_nil
end
- it "should log the inability to fetch from API at debug level" do
- expect(Bundler).to receive_message_chain(:ui, :debug).with("could not fetch from the dependency API, trying the full index")
- subject.specs(gem_names, full_dependency_list, last_spec_list)
- end
-
context "debug logging is not on" do
before { allow(Bundler).to receive_message_chain(:ui, :debug?).and_return(false) }
@@ -164,22 +156,36 @@ describe Bundler::Fetcher::Dependency do
end
end
+ shared_examples_for "the error suggests retrying with the full index" do
+ it "should log the inability to fetch from API at debug level" do
+ expect(Bundler).to receive_message_chain(:ui, :debug).with("could not fetch from the dependency API\nit's suggested to retry using the full index via `bundle install --full-index`")
+ subject.specs(gem_names, full_dependency_list, last_spec_list)
+ end
+ end
+
context "when an HTTPError occurs" do
before { allow(subject).to receive(:dependency_specs) { raise Bundler::HTTPError.new } }
it_behaves_like "the error is properly handled"
+ it_behaves_like "the error suggests retrying with the full index"
end
- context "when a MarshalError occurs" do
- before { allow(subject).to receive(:dependency_specs) { raise Bundler::MarshalError.new } }
+ context "when a GemspecError occurs" do
+ before { allow(subject).to receive(:dependency_specs) { raise Bundler::GemspecError.new } }
it_behaves_like "the error is properly handled"
+ it_behaves_like "the error suggests retrying with the full index"
end
- context "when a GemspecError occurs" do
- before { allow(subject).to receive(:dependency_specs) { raise Bundler::GemspecError.new } }
+ context "when a MarshalError occurs" do
+ before { allow(subject).to receive(:dependency_specs) { raise Bundler::MarshalError.new } }
it_behaves_like "the error is properly handled"
+
+ it "should log the inability to fetch from API and mention retrying" do
+ expect(Bundler).to receive_message_chain(:ui, :debug).with("could not fetch from the dependency API, trying the full index")
+ subject.specs(gem_names, full_dependency_list, last_spec_list)
+ end
end
end