diff options
author | The Bundler Bot <bot@bundler.io> | 2018-02-01 16:52:55 +0000 |
---|---|---|
committer | Colby Swandale <me@colby.fyi> | 2018-04-20 10:27:32 +1000 |
commit | da1589d45bb92c3b375f8a45ff0997132bdf6a69 (patch) | |
tree | 787fb8c58d714693958e292770735894b84a1f2c | |
parent | 84c11771fd8d194973f115ba7c889336c62cdfcd (diff) | |
download | bundler-da1589d45bb92c3b375f8a45ff0997132bdf6a69.tar.gz |
Auto merge of #6211 - papanikge:add-source-when-failing, r=segiddins
Add explicit source when available in the error msg upon failure
### What was the end-user problem that led to this PR?
My bundling failed and the command that `bundler` output was wrong-ish, in the sense that my gem was suppose to come from a different source.
### What was your diagnosis of the problem?
The error message was not explicit.
### What is your fix for the problem, implemented in this PR?
Bundler now explicitly print the source when there's just one. I think it's a good case just to print it when there's one. If there are more it's ambiguous, so we fallback to the old way. Maybe we could have a warning there that the command might not be exactly what the user wants.
### Why did you choose this fix out of the possible options?
See previous answer. I didn't find any easier ways of getting the source url.
Let me know if there are better implementations :)
(cherry picked from commit 8a32d643d0daef1776c075404820cc86ee699ce4)
-rw-r--r-- | lib/bundler/installer/gem_installer.rb | 7 | ||||
-rw-r--r-- | spec/commands/install_spec.rb | 4 | ||||
-rw-r--r-- | spec/install/failure_spec.rb | 37 |
3 files changed, 43 insertions, 5 deletions
diff --git a/lib/bundler/installer/gem_installer.rb b/lib/bundler/installer/gem_installer.rb index 086b763d20..a38f8d95be 100644 --- a/lib/bundler/installer/gem_installer.rb +++ b/lib/bundler/installer/gem_installer.rb @@ -44,7 +44,12 @@ module Bundler end def gem_install_message - "Make sure that `gem install #{spec.name} -v '#{spec.version}'` succeeds before bundling." + remotes = spec.source.remotes + if remotes.size == 1 + "Make sure that `gem install #{spec.name} -v '#{spec.version}' --source '#{remotes.first}'` succeeds before bundling." + else + "Make sure that `gem install #{spec.name} -v '#{spec.version}'` succeeds before bundling." + end end def spec_settings diff --git a/spec/commands/install_spec.rb b/spec/commands/install_spec.rb index 4cb8584633..b6e89d70da 100644 --- a/spec/commands/install_spec.rb +++ b/spec/commands/install_spec.rb @@ -348,14 +348,14 @@ RSpec.describe "bundle install with gem sources" do end install_gemfile <<-G, :full_index => true - source "file://#{gem_repo2}" + source "file:\/\/localhost#{gem_repo2}" gem "ajp-rails", "0.0.0" G expect(last_command.stdboth).not_to match(/Error Report/i) expect(last_command.bundler_err).to include("An error occurred while installing ajp-rails (0.0.0), and Bundler cannot continue."). - and include("Make sure that `gem install ajp-rails -v '0.0.0'` succeeds before bundling.") + and include("Make sure that `gem install ajp-rails -v '0.0.0' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling.") end it "doesn't blow up when the local .bundle/config is empty" do diff --git a/spec/install/failure_spec.rb b/spec/install/failure_spec.rb index 896138c659..ea97ac837b 100644 --- a/spec/install/failure_spec.rb +++ b/spec/install/failure_spec.rb @@ -15,12 +15,45 @@ RSpec.describe "bundle install" do end install_gemfile <<-G - source "file:#{gem_repo2}" + source "file:\/\/localhost#{gem_repo2}" gem "rails" G expect(last_command.bundler_err).to end_with(<<-M.strip) An error occurred while installing activesupport (2.3.2), and Bundler cannot continue. -Make sure that `gem install activesupport -v '2.3.2'` succeeds before bundling. +Make sure that `gem install activesupport -v '2.3.2' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling. + +In Gemfile: + rails was resolved to 2.3.2, which depends on + actionmailer was resolved to 2.3.2, which depends on + activesupport + M + end + + it "prints out the hint for the remote source when available" do + build_repo2 do + build_gem "activesupport", "2.3.2" do |s| + s.extensions << "Rakefile" + s.write "Rakefile", <<-RUBY + task :default do + abort "make installing activesupport-2.3.2 fail" + end + RUBY + end + end + + build_repo4 do + build_gem "a" + end + + install_gemfile <<-G + source "file:\/\/localhost#{gem_repo4}" + source "file:\/\/localhost#{gem_repo2}" do + gem "rails" + end + G + expect(last_command.bundler_err).to end_with(<<-M.strip) +An error occurred while installing activesupport (2.3.2), and Bundler cannot continue. +Make sure that `gem install activesupport -v '2.3.2' --source 'file://localhost#{gem_repo2}/'` succeeds before bundling. In Gemfile: rails was resolved to 2.3.2, which depends on |