diff options
-rw-r--r-- | lib/bundler/cli/outdated.rb | 6 | ||||
-rw-r--r-- | lib/bundler/definition.rb | 24 | ||||
-rw-r--r-- | lib/bundler/inline.rb | 2 | ||||
-rw-r--r-- | lib/bundler/settings.rb | 1 | ||||
-rw-r--r-- | man/bundle-config.1 | 3 | ||||
-rw-r--r-- | man/bundle-config.1.txt | 4 | ||||
-rw-r--r-- | man/bundle-config.ronn | 2 | ||||
-rw-r--r-- | spec/install/gemfile/platform_spec.rb | 37 | ||||
-rw-r--r-- | spec/runtime/require_spec.rb | 2 |
9 files changed, 32 insertions, 49 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..fca7d35aaa 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 @@ -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 @@ -548,6 +544,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| @@ -892,17 +894,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/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`): diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index 52e1cf86fa..c637eeee0c 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,28 +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 - end - - context "when disable_platform_warnings is true" do - before { bundle! "config set disable_platform_warnings true" } + expect(err).to be_empty - 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)}" + lockfile_should_be <<-L + GEM + remote: #{file_uri_for(gem_repo1)}/ + specs: + rack (1.0.0) - gem "rack", :platform => [:mingw, :mswin, :x64_mingw, :jruby] - G + PLATFORMS + java + ruby + x64-mingw32 + x86-mingw32 + x86-mswin32 - bundle! "install" + DEPENDENCIES + rack - expect(out).not_to match(/The dependency (.*) will be unused/) - end + BUNDLED WITH + #{Bundler::VERSION} + L end end 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" |