diff options
| author | George Papanikolaou <gpapanikolaou@skroutz.gr> | 2017-12-11 13:18:30 +0200 |
|---|---|---|
| committer | George Papanikolaou <gpapanikolaou@skroutz.gr> | 2018-01-25 22:13:11 +0200 |
| commit | 99d7fd1333ee9fcb4fbdb04a6c5ae51412c79d08 (patch) | |
| tree | 6dc156c6b553e9cd008984503b5ae937b4706fc5 | |
| parent | 7fc622bd308f60c82a0a794d926d3d51b59f2067 (diff) | |
| download | bundler-99d7fd1333ee9fcb4fbdb04a6c5ae51412c79d08.tar.gz | |
Add explicit source when available in the error msg upon failure
The error-message function did not provide an explicit source,
and that could lead in some confusion especially with big Gemfiles.
The command that is output, should be valid.
| -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 44006be52e..27abe9fcc3 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 |
