summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAgrim Mittal <agrimmittal97@gmail.com>2018-03-20 12:42:51 +0530
committerAgrim Mittal <agrimmittal97@gmail.com>2018-07-02 11:00:23 +0530
commit1ecfd96b544e75af75e0b530f7501840075c0c45 (patch)
treee1341359f1430eea53a750a43081875b1703ac86
parentfc06037bcd36d7484e916beae68c9244de0bc6b7 (diff)
downloadbundler-1ecfd96b544e75af75e0b530f7501840075c0c45.tar.gz
Separate conditions for version specification
-rw-r--r--lib/bundler/dsl.rb14
1 files changed, 10 insertions, 4 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 7ba75fa6f8..f22571cd63 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -103,13 +103,19 @@ module Bundler
# if there's already a dependency with this name we try to prefer one
if current = @dependencies.find {|d| d.name == dep.name }
deleted_dep = @dependencies.delete(current) if current.type == :development
-
if current.requirement != dep.requirement
unless deleted_dep
return if dep.type == :development
- 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}). " \
- "If you want to update the gem version, run `bundle update #{current.name}`. You may need to change the version requirement specified in the Gemfile if it's too restrictive"
+
+ # If no version is specified on adding gem
+ if "#{dep.requirement}" == ">= 0"
+ raise GemfileError, "Gem `#{current.name}` is already added.\n" \
+ "If you want to update the gem version, run `bundle update #{current.name}`."
+ 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}). " \
+ "If you want to update the gem version, run `bundle update #{current.name}`. You may need to change the version requirement specified in the Gemfile if it's too restrictive"
+ end
end
else