From b8da66bf6efde9f995999c2dce7e36603d9c2bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 17 Jan 2020 14:10:46 +0100 Subject: Revert "Revert "Add all platforms to lockfile by default"" This reverts commit b5766564fb6ad9c74c3b87ad6b2965f3b9095d08. --- lib/bundler/cli/outdated.rb | 6 ++++-- lib/bundler/definition.rb | 8 +++++++- spec/install/gemfile/platform_spec.rb | 26 ++++++++++++++++++++++---- spec/runtime/require_spec.rb | 2 +- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb index 3d4922f8b5..5f065654b1 100644 --- a/lib/bundler/cli/outdated.rb +++ b/lib/bundler/cli/outdated.rb @@ -76,6 +76,8 @@ module Bundler next unless gems.empty? || gems.include?(current_spec.name) active_spec = retrieve_active_spec(definition, current_spec) + next unless active_spec + next unless filter_options_patch.empty? || update_present_via_semver_portions(current_spec, active_spec, options) gem_outdated = Gem::Version.new(active_spec.version) > Gem::Version.new(current_spec.version) @@ -144,6 +146,8 @@ module Bundler end def retrieve_active_spec(definition, current_spec) + return unless current_spec.match_platform(Bundler.local_platform) + if strict active_spec = definition.find_resolved_spec(current_spec) else @@ -231,8 +235,6 @@ module Bundler end def update_present_via_semver_portions(current_spec, active_spec, options) - return false if active_spec.nil? - current_major = current_spec.version.segments.first active_major = active_spec.version.segments.first diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index efd7618194..d723384189 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -117,7 +117,7 @@ module Bundler end @unlocking ||= @unlock[:ruby] ||= (!@locked_ruby_version ^ !@ruby_version) - add_current_platform unless Bundler.frozen_bundle? + add_platforms unless Bundler.frozen_bundle? converge_path_sources_to_gemspec_sources @path_changes = converge_paths @@ -548,6 +548,12 @@ module Bundler private + def add_platforms + (@dependencies.flat_map(&:expanded_platforms) + current_platforms).uniq.each do |platform| + add_platform(platform) + end + end + def current_platforms current_platform = Bundler.local_platform [].tap do |platforms| diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index 52e1cf86fa..2bbda133c9 100644 --- a/spec/install/gemfile/platform_spec.rb +++ b/spec/install/gemfile/platform_spec.rb @@ -378,7 +378,7 @@ RSpec.describe "bundle install with platform conditionals" do expect(out).not_to match(/Could not find gem 'some_gem/) end - it "prints a helpful warning when a dependency is unused on any platform" do + it "resolves all platforms by default and without warning messages" do simulate_platform "ruby" simulate_ruby_engine "ruby" @@ -390,9 +390,27 @@ RSpec.describe "bundle install with platform conditionals" do bundle! "install" - expect(err).to include <<-O.strip -The dependency #{Gem::Dependency.new("rack", ">= 0")} will be unused by any of the platforms Bundler is installing for. Bundler is installing for ruby but the dependency is only for x86-mingw32, x86-mswin32, x64-mingw32, java. To add those platforms to the bundle, run `bundle lock --add-platform x86-mingw32 x86-mswin32 x64-mingw32 java`. - O + expect(err).to be_empty + + lockfile_should_be <<-L + GEM + remote: #{file_uri_for(gem_repo1)}/ + specs: + rack (1.0.0) + + PLATFORMS + java + ruby + x64-mingw32 + x86-mingw32 + x86-mswin32 + + DEPENDENCIES + rack + + BUNDLED WITH + #{Bundler::VERSION} + L end context "when disable_platform_warnings is true" do diff --git a/spec/runtime/require_spec.rb b/spec/runtime/require_spec.rb index a2e6ba7244..3b9021b4fc 100644 --- a/spec/runtime/require_spec.rb +++ b/spec/runtime/require_spec.rb @@ -423,7 +423,7 @@ RSpec.describe "Bundler.require with platform specific dependencies" do source "#{file_uri_for(gem_repo1)}" platforms :#{not_local_tag} do - gem "fail", :require => "omgomg" + gem "platform_specific", :require => "omgomg" end gem "rack", "1.0.0" -- cgit v1.2.1 From 3aebd84b62a1249766e2b78f83a2a9dd395b3b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 17 Jan 2020 14:11:03 +0100 Subject: Revert "Revert "Remove now meaningless warning"" This reverts commit e93bce3b206895a46b9fb5889c5f908fd29ad554. --- lib/bundler/definition.rb | 12 +----------- spec/install/gemfile/platform_spec.rb | 19 ------------------- 2 files changed, 1 insertion(+), 30 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index d723384189..1bffdbcc6f 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -898,17 +898,7 @@ module Bundler dependencies.each do |dep| dep = Dependency.new(dep, ">= 0") unless dep.respond_to?(:name) next if !remote && !dep.current_platform? - 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| + dep.gem_platforms(sorted_platforms).each do |p| deps << DepProxy.new(dep, p) if remote || p == generic_local_platform end end diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index 2bbda133c9..c637eeee0c 100644 --- a/spec/install/gemfile/platform_spec.rb +++ b/spec/install/gemfile/platform_spec.rb @@ -412,25 +412,6 @@ RSpec.describe "bundle install with platform conditionals" do #{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 v1.2.1 From fea5721f74d72bea2d2429644d966edcee471cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 17 Jan 2020 14:12:21 +0100 Subject: Revert "Revert "Remove now meaningless setting"" This reverts commit b4cc36deb9749fba603d149e2b8e71b10cb331f1. --- lib/bundler/inline.rb | 2 +- lib/bundler/settings.rb | 1 - man/bundle-config.1 | 3 --- man/bundle-config.1.txt | 4 ---- man/bundle-config.ronn | 2 -- 5 files changed, 1 insertion(+), 11 deletions(-) diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb index f1f77a7a9c..59211193d4 100644 --- a/lib/bundler/inline.rb +++ b/lib/bundler/inline.rb @@ -58,7 +58,7 @@ def gemfile(install = false, options = {}, &gemfile) Bundler.ui = install ? ui : Bundler::UI::Silent.new if install || definition.missing_specs? - Bundler.settings.temporary(:inline => true, :disable_platform_warnings => true) do + Bundler.settings.temporary(:inline => true) do installer = Bundler::Installer.install(Bundler.root, definition, :system => true) installer.post_install_messages.each do |name, message| Bundler.ui.info "Post-install message from #{name}:\n#{message}" diff --git a/lib/bundler/settings.rb b/lib/bundler/settings.rb index afbb02397c..23ae66efa0 100644 --- a/lib/bundler/settings.rb +++ b/lib/bundler/settings.rb @@ -22,7 +22,6 @@ module Bundler disable_exec_load disable_local_branch_check disable_multisource - disable_platform_warnings disable_shared_gems disable_version_check force_ruby_platform diff --git a/man/bundle-config.1 b/man/bundle-config.1 index 58be36c5c6..9376693f7c 100644 --- a/man/bundle-config.1 +++ b/man/bundle-config.1 @@ -187,9 +187,6 @@ The following is a list of all configuration keys and their purpose\. You can le \fBdisable_multisource\fR (\fBBUNDLE_DISABLE_MULTISOURCE\fR): When set, Gemfiles containing multiple sources will produce errors instead of warnings\. Use \fBbundle config unset disable_multisource\fR to unset\. . .IP "\(bu" 4 -\fBdisable_platform_warnings\fR (\fBBUNDLE_DISABLE_PLATFORM_WARNINGS\fR): Disable warnings during bundle install when a dependency is unused on the current platform\. -. -.IP "\(bu" 4 \fBdisable_shared_gems\fR (\fBBUNDLE_DISABLE_SHARED_GEMS\fR): Stop Bundler from accessing gems installed to RubyGems\' normal location\. . .IP "\(bu" 4 diff --git a/man/bundle-config.1.txt b/man/bundle-config.1.txt index d6632792e5..135028fbe5 100644 --- a/man/bundle-config.1.txt +++ b/man/bundle-config.1.txt @@ -214,10 +214,6 @@ LIST OF AVAILABLE KEYS files containing multiple sources will produce errors instead of warnings. Use bundle config unset disable_multisource to unset. - o disable_platform_warnings (BUNDLE_DISABLE_PLATFORM_WARNINGS): Dis- - able warnings during bundle install when a dependency is unused on - the current platform. - o disable_shared_gems (BUNDLE_DISABLE_SHARED_GEMS): Stop Bundler from accessing gems installed to RubyGems' normal location. diff --git a/man/bundle-config.ronn b/man/bundle-config.ronn index 6b0e044cd3..b241bba505 100644 --- a/man/bundle-config.ronn +++ b/man/bundle-config.ronn @@ -181,8 +181,6 @@ learn more about their operation in [bundle install(1)](bundle-install.1.html). When set, Gemfiles containing multiple sources will produce errors instead of warnings. Use `bundle config unset disable_multisource` to unset. -* `disable_platform_warnings` (`BUNDLE_DISABLE_PLATFORM_WARNINGS`): - Disable warnings during bundle install when a dependency is unused on the current platform. * `disable_shared_gems` (`BUNDLE_DISABLE_SHARED_GEMS`): Stop Bundler from accessing gems installed to RubyGems' normal location. * `disable_version_check` (`BUNDLE_DISABLE_VERSION_CHECK`): -- cgit v1.2.1 From a123d2aec2ad70122a24e2dc96268051811c9987 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Fri, 17 Jan 2020 14:12:32 +0100 Subject: Revert "Revert "Remove now unused method"" This reverts commit 13cef81582858af9509726f3a24a817cf029ad9b. --- lib/bundler/definition.rb | 4 ---- 1 file changed, 4 deletions(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 1bffdbcc6f..fca7d35aaa 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -523,10 +523,6 @@ module Bundler raise InvalidOption, "Unable to remove the platform `#{platform}` since the only platforms are #{@platforms.join ", "}" end - def add_current_platform - current_platforms.each {|platform| add_platform(platform) } - end - def find_resolved_spec(current_spec) specs.find_by_name_and_platform(current_spec.name, current_spec.platform) end -- cgit v1.2.1