diff options
author | Samuel Giddins <segiddins@segiddins.me> | 2016-09-19 21:45:55 +0200 |
---|---|---|
committer | Samuel Giddins <segiddins@segiddins.me> | 2016-09-19 21:45:55 +0200 |
commit | 483e93709a96a51f63f039d19e56ce41a83c356b (patch) | |
tree | 37d3df5f596eac77fd15087fe26ee406690fbf77 /lib/bundler | |
parent | c36e18098e3efc9f4bf63e4a05c98494b8c7b502 (diff) | |
download | bundler-483e93709a96a51f63f039d19e56ce41a83c356b.tar.gz |
[Definition] Print a helpful warning when a dependency is unused on any platform
Diffstat (limited to 'lib/bundler')
-rw-r--r-- | lib/bundler/definition.rb | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 12951cdf9c..9fbacf2cb4 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -808,8 +808,16 @@ module Bundler deps = [] dependencies.each do |dep| dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name) - next unless remote || dep.current_platform? - dep.gem_platforms(@platforms).each do |p| + next if !remote && !dep.current_platform? + platforms = dep.gem_platforms(@platforms) + if platforms.empty? + Bundler.ui.warn \ + "The dependency #{dep} will be unused by any of the platforms Bundler is installing for. " \ + "Bundler is installing for #{@platforms.join ", "} but the dependency " \ + "is only for #{dep.platforms.map {|p| Dependency::PLATFORM_MAP[p] }.join ", "}. " \ + "To add those platforms to the bundle, run `bundle lock --add-platform #{dep.platforms.join ", "}`." + end + platforms.each do |p| deps << DepProxy.new(dep, p) if remote || p == generic_local_platform end end |