[前][次][番号順一覧][スレッド一覧]

ruby-changes:57788

From: David <ko1@a...>
Date: Wed, 18 Sep 2019 21:31:43 +0900 (JST)
Subject: [ruby-changes:57788] 6f16ededdd (master): [bundler/bundler] Revert "Remove now meaningless warning"

https://git.ruby-lang.org/ruby.git/commit/?id=6f16ededdd

From 6f16ededdd5eed8bab9e4f4cb70032a151fbc405 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?David=20Rodr=C3=ADguez?= <deivid.rodriguez@r...>
Date: Wed, 21 Aug 2019 20:52:35 +0200
Subject: [bundler/bundler] Revert "Remove now meaningless warning"

This reverts commit 00b095b98fe4bd44950beaf3bc9f1d91eac7b69e.

https://github.com/bundler/bundler/commit/e93bce3b20

diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 08bd19e..3f5e8ce 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -896,7 +896,17 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L896
       dependencies.each do |dep|
         dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name)
         next if !remote && !dep.current_platform?
-        dep.gem_platforms(sorted_platforms).each do |p|
+        platforms = dep.gem_platforms(sorted_platforms)
+        if platforms.empty? && !Bundler.settings[:disable_platform_warnings]
+          mapped_platforms = dep.expanded_platforms
+          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 #{mapped_platforms.join ", "}. " \
+            "To add those platforms to the bundle, " \
+            "run `bundle lock --add-platform #{mapped_platforms.join " "}`."
+        end
+        platforms.each do |p|
           deps << DepProxy.new(dep, p) if remote || p == generic_local_platform
         end
       end
diff --git a/spec/bundler/install/gemfile/platform_spec.rb b/spec/bundler/install/gemfile/platform_spec.rb
index d065e10..4cbf238 100644
--- a/spec/bundler/install/gemfile/platform_spec.rb
+++ b/spec/bundler/install/gemfile/platform_spec.rb
@@ -406,6 +406,25 @@ RSpec.describe "bundle install with platform conditionals" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gemfile/platform_spec.rb#L406
          #{Bundler::VERSION}
     L
   end
+
+  context "when disable_platform_warnings is true" do
+    before { bundle! "config set disable_platform_warnings true" }
+
+    it "does not print the warning when a dependency is unused on any platform" do
+      simulate_platform "ruby"
+      simulate_ruby_engine "ruby"
+
+      gemfile <<-G
+        source "#{file_uri_for(gem_repo1)}"
+
+        gem "rack", :platform => [:mingw, :mswin, :x64_mingw, :jruby]
+      G
+
+      bundle! "install"
+
+      expect(out).not_to match(/The dependency (.*) will be unused/)
+    end
+  end
 end
 
 RSpec.describe "when a gem has no architecture" do
-- 
cgit v0.10.2


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]