diff options
author | The Bundler Bot <bot@bundler.io> | 2017-02-07 16:52:01 +0000 |
---|---|---|
committer | The Bundler Bot <bot@bundler.io> | 2017-02-07 16:52:01 +0000 |
commit | cd872ef1e8281252786535df960275cd391933bc (patch) | |
tree | d5735c2681751bf6a1dbc7af0aaf28f210a3cc77 | |
parent | ca725b7fef4d28e58270ec731036c51e7c4f0878 (diff) | |
parent | 98ed0b23441a2785fff8617d50d88fcb0bf1efc7 (diff) | |
download | bundler-cd872ef1e8281252786535df960275cd391933bc.tar.gz |
Auto merge of #5393 - 5t111111:fix-warning-when-a-dependency-unused, r=segiddins
Fix misleading warning message when a dependency is unused on any platform
The current warning message for a dep with empty platform is misleading/confusing. You see a sort of the below warning when you `bundle install`,
```
The dependency tzinfo-data (>= 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 mingw, mswin, x64_mingw, jruby`.
```
However, there two issues exist in this message "run `bundle lock --add-platform mingw, mswin, x64_mingw, jruby`":
- You must not have comma (,) for separators
- these commas will be considered as comma itself. see [here](https://github.com/bundler/bundler/blob/242fcbcb2d15d39c63e3441756b77fbfcc1b73b2/lib/bundler/cli/lock.rb#L34-L41)
- mingw, mswin, x64_mingw, jruby are not valid platforms
- platforms must be specified as the formats that rubygems can understand, like (x86-mingw32, x86-mswin32, x64-mingw32, java)
This fixes these issues.
-rw-r--r-- | lib/bundler/definition.rb | 6 | ||||
-rw-r--r-- | spec/install/gemfile/platform_spec.rb | 4 |
2 files changed, 6 insertions, 4 deletions
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 85ee5a9ebf..5a90b84125 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -825,11 +825,13 @@ module Bundler next if !remote && !dep.current_platform? platforms = dep.gem_platforms(@platforms) if platforms.empty? + mapped_platforms = dep.platforms.map {|p| Dependency::PLATFORM_MAP[p] } 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 #{dep.platforms.map {|p| Dependency::PLATFORM_MAP[p] }.join ", "}. " \ - "To add those platforms to the bundle, run `bundle lock --add-platform #{dep.platforms.join ", "}`." + "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 diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb index 3889ad5708..3b28a58ecc 100644 --- a/spec/install/gemfile/platform_spec.rb +++ b/spec/install/gemfile/platform_spec.rb @@ -212,13 +212,13 @@ RSpec.describe "bundle install with platform conditionals" do gemfile <<-G source "file://#{gem_repo1}" - gem "rack", :platform => :jruby + gem "rack", :platform => [:mingw, :mswin, :x64_mingw, :jruby] G bundle! "install" expect(out).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 java. To add those platforms to the bundle, run `bundle lock --add-platform jruby`. +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 end |