From 073bef728932d268b0b00f3e00eb679e8b419272 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 10 Nov 2020 15:54:00 +0100 Subject: [PATCH] Merge pull request #4052 from rubygems/revert_automultiplatform_again Revert resolving all Gemfile platforms automatically (cherry picked from commit a9b3694abd272ecba32e0d9698496b7e7ea834c4) --- bundler/lib/bundler/cli/outdated.rb | 6 ++---- bundler/lib/bundler/definition.rb | 8 +++----- bundler/spec/install/gemfile/platform_spec.rb | 7 +------ 3 files changed, 6 insertions(+), 15 deletions(-) diff --git a/bundler/lib/bundler/cli/outdated.rb b/bundler/lib/bundler/cli/outdated.rb index 109c5f417ffd..b8d9be20b6a6 100644 --- a/bundler/lib/bundler/cli/outdated.rb +++ b/bundler/lib/bundler/cli/outdated.rb @@ -76,8 +76,6 @@ def run 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) @@ -146,8 +144,6 @@ def nothing_outdated_message 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 @@ -233,6 +229,8 @@ def check_for_deployment_mode! 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/bundler/lib/bundler/definition.rb b/bundler/lib/bundler/definition.rb index 1a4b703aa55d..78f3abffbd9d 100644 --- a/bundler/lib/bundler/definition.rb +++ b/bundler/lib/bundler/definition.rb @@ -118,7 +118,7 @@ def initialize(lockfile, dependencies, sources, unlock, ruby_version = nil, opti end @unlocking ||= @unlock[:ruby] ||= (!@locked_ruby_version ^ !@ruby_version) - add_platforms unless Bundler.frozen_bundle? + add_current_platform unless Bundler.frozen_bundle? converge_path_sources_to_gemspec_sources @path_changes = converge_paths @@ -547,10 +547,8 @@ def unlocking? private - def add_platforms - (@dependencies.flat_map(&:expanded_platforms) + current_platforms).uniq.each do |platform| - add_platform(platform) - end + def add_current_platform + current_platforms.each {|platform| add_platform(platform) } end def current_platforms diff --git a/bundler/spec/install/gemfile/platform_spec.rb b/bundler/spec/install/gemfile/platform_spec.rb index a165f62bdbd9..f6cb60250b67 100644 --- a/bundler/spec/install/gemfile/platform_spec.rb +++ b/bundler/spec/install/gemfile/platform_spec.rb @@ -430,7 +430,7 @@ expect(out).not_to match(/Could not find gem 'some_gem/) end - it "resolves all platforms by default and without warning messages" do + it "does not print a warning when a dependency is unused on a platform different from the current one" do simulate_platform "ruby" gemfile <<-G @@ -447,14 +447,9 @@ GEM remote: #{file_uri_for(gem_repo1)}/ specs: - rack (1.0.0) PLATFORMS - java ruby - x64-mingw32 - x86-mingw32 - x86-mswin32 DEPENDENCIES rack