From 96d7b91c9a1a72c8591fb7808d5d75d0fb245f8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Thu, 29 Oct 2020 17:42:14 +0100 Subject: [PATCH] Revert resolving all Gemfile platforms automatically This is the second time I revert this change, since I have found some cases where this might cause pain, and I want to battle test multiplatform fixes before attempting this. I think ideally, when we introduce something like this, we should consider making it opt-in by recording this intention in the `Gemfile`, maybe with an unscoped `platforms` DSL, or by an explicit CLI flag, like `bundle install --all-platforms`, or `bundle lock --all-platforms`. The part I'm not reverting is removing the warning about dependencies being unused under the current platform, since it is pretty much expected on a multiplatform context. --- 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 fc35f31be16c..9760887eeadd 100644 --- a/bundler/lib/bundler/definition.rb +++ b/bundler/lib/bundler/definition.rb @@ -123,7 +123,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 @@ -554,10 +554,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 456237372b41..729b6e0106fd 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