diff options
author | David RodrÃguez <deivid.rodriguez@riseup.net> | 2023-12-01 16:56:17 +0100 |
---|---|---|
committer | Hiroshi SHIBATA <hsbt@ruby-lang.org> | 2023-12-05 14:28:42 +0900 |
commit | 16669cd6ad737a99782655084fabf444f7dc93eb (patch) | |
tree | 317d512c7a63484e02694b9cbbcb32e5c8bc745b /lib/bundler | |
parent | 7ab877761e0577b1cd29811173971305bfadcead (diff) | |
download | ruby-16669cd6ad737a99782655084fabf444f7dc93eb.tar.gz |
[rubygems/rubygems] Fix crash when duplicating a dev dependency in Gemfile & gemspec
https://github.com/rubygems/rubygems/commit/e78c0a4a48
Diffstat (limited to 'lib/bundler')
-rw-r--r-- | lib/bundler/dsl.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index f3968d8a6e..6c627d28be 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -102,12 +102,13 @@ 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 } + # Always prefer the dependency from the Gemfile + deleted_dep = @dependencies.delete(current) if current.type == :development + if current.requirement != dep.requirement current_requirement_open = current.requirements_list.include?(">= 0") if current.type == :development - @dependencies.delete(current) - unless current_requirement_open || dep.type == :development Bundler.ui.warn "A gemspec development dependency (#{dep.name}, #{current.requirement}) is being overridden by a Gemfile dependency (#{dep.name}, #{dep.requirement}).\n" \ "This behaviour may change in the future. Please remove either of them, or make sure they both have the same requirement\n" \ @@ -129,12 +130,13 @@ module Bundler "You specified: #{current.name} (#{current.requirement}) and #{dep.name} (#{dep.requirement})" \ "#{update_prompt}" end + elsif current.type == :development || dep.type == :development + return if deleted_dep.nil? elsif current.source != dep.source - return if dep.type == :development raise GemfileError, "You cannot specify the same gem twice coming from different sources.\n" \ "You specified that #{dep.name} (#{dep.requirement}) should come from " \ "#{current.source || "an unspecified source"} and #{dep.source}\n" - elsif current.type != :development && dep.type != :development + 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" \ "Remove any duplicate entries and specify the gem only once.\n" \ |