diff options
author | André Arko <andre@arko.net> | 2013-10-19 16:42:37 -0700 |
---|---|---|
committer | André Arko <andre@arko.net> | 2013-10-19 16:42:37 -0700 |
commit | 3ee826035461bbbdbd1ae2c27b8f2cb773f4feb8 (patch) | |
tree | c9a425ffe8139f869fca39fd1af95db9ae62741e | |
parent | 9944d43773141f3d2e69947b43e42fa68b2fc612 (diff) | |
parent | a5d3d1522f0f37327339715432ecf33434273420 (diff) | |
download | bundler-3ee826035461bbbdbd1ae2c27b8f2cb773f4feb8.tar.gz |
Merge pull request #2679 from jendiamond/same_gem_twice_boo
warn if the same gem (same version) is added twice
-rw-r--r-- | lib/bundler/dsl.rb | 10 | ||||
-rw-r--r-- | spec/install/gems/simple_case_spec.rb | 11 |
2 files changed, 18 insertions, 3 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 947aca7ba8..6d4d1e70e8 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -83,10 +83,14 @@ module Bundler elsif dep.type == :development return else - raise GemfileError, "You cannot specify the same gem twice with different version requirements. \n" \ - "You specified: #{current.name} (#{current.requirement}) and " \ - "#{dep.name} (#{dep.requirement})\n" + raise GemfileError, "You cannot specify the same gem twice with different version requirements.\n" \ + "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})" end + + else + Bundler.ui.warn "Your Gemfile lists the gem #{current.name} (#{current.requirement}) more than once.\n" \ + "You should probably keep only one of them.\n" \ + "While it's not a problem now, it could cause errors if you change the version of just one of them later." end if current.source != dep.source diff --git a/spec/install/gems/simple_case_spec.rb b/spec/install/gems/simple_case_spec.rb index 630ea083c1..b453975399 100644 --- a/spec/install/gems/simple_case_spec.rb +++ b/spec/install/gems/simple_case_spec.rb @@ -832,4 +832,15 @@ describe "bundle install with gem sources" do bundle :install, :artifice => 'endpoint_marshal_fail' # force gemspec load should_be_installed "activesupport 2.3.2" end + + describe "#gem" do + it "will display a Warning if the gem is duplicated" do + gemfile <<-G + gem 'rails', '~> 4.0.0' + gem 'rails', '~> 4.0.0' + G + bundle :install + expect(out).to include("more than once") + end + end end |