diff options
author | Homu <homu@barosl.com> | 2016-02-24 06:43:39 +0900 |
---|---|---|
committer | Homu <homu@barosl.com> | 2016-02-24 06:43:39 +0900 |
commit | c1f6b0ca96a5593e99a7b9133aff88ade1e38918 (patch) | |
tree | 79beeeedc140799b09840f727479056e8a78c62b | |
parent | 33f6afe55987787af530a630ba4430f61745047a (diff) | |
parent | 15cbad40fc5ad31f098e417f057e38ceae191680 (diff) | |
download | bundler-c1f6b0ca96a5593e99a7b9133aff88ade1e38918.tar.gz |
Auto merge of #4262 - RochesterinNYC:improved-error-message-when-different-platform, r=segiddins
Add platform info to error message for different platform in gemspec than Gemfile.lock
- Addresses #4259
-rw-r--r-- | lib/bundler/resolver.rb | 19 | ||||
-rw-r--r-- | spec/install/gemfile/git_spec.rb | 39 | ||||
-rw-r--r-- | spec/support/builders.rb | 8 |
3 files changed, 60 insertions, 6 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb index d22ab34e98..48f0d468b6 100644 --- a/lib/bundler/resolver.rb +++ b/lib/bundler/resolver.rb @@ -341,10 +341,11 @@ module Bundler "try passing them all to `bundle update`" elsif requirement.source name = requirement.name - versions = @source_requirements[name][name].map(&:version) - message = String.new("Could not find gem '#{requirement}' in #{requirement.source}.\n") - message << if versions.any? - "Source contains '#{name}' at: #{versions.join(", ")}" + specs = @source_requirements[name][name] + versions_with_platforms = specs.map {|s| [s.version, s.platform] } + message = String.new("Could not find gem '#{requirement}' in #{requirement.source}.\n") + message << if versions_with_platforms.any? + "Source contains '#{name}' at: #{formatted_versions_with_platforms(versions_with_platforms)}" else "Source does not contain any versions of '#{requirement}'" end @@ -355,5 +356,15 @@ module Bundler raise GemNotFound, message end end + + def formatted_versions_with_platforms(versions_with_platforms) + version_platform_strs = versions_with_platforms.map do |vwp| + version = vwp.first + platform = vwp.last + version_platform_str = String.new(version.to_s) + version_platform_str << " #{platform}" unless platform.nil? + end + version_platform_strs.join(", ") + end end end diff --git a/spec/install/gemfile/git_spec.rb b/spec/install/gemfile/git_spec.rb index c5c70c2c12..66a721521e 100644 --- a/spec/install/gemfile/git_spec.rb +++ b/spec/install/gemfile/git_spec.rb @@ -82,7 +82,44 @@ describe "bundle install with git sources" do gem "foo", "1.1", :git => "#{lib_path("foo-1.0")}" G - expect(out).to include("Source contains 'foo' at: 1.0") + expect(out).to include("Source contains 'foo' at: 1.0 ruby") + end + + it "complains with version and platform if pinned specs don't exist in the git repo" do + simulate_platform "java" + + build_git "only_java" do |s| + s.platform = "java" + end + + install_gemfile <<-G + platforms :jruby do + gem "only_java", "1.2", :git => "#{lib_path("only_java-1.0-java")}" + end + G + + expect(out).to include("Source contains 'only_java' at: 1.0 java") + end + + it "complains with multiple versions and platforms if pinned specs don't exist in the git repo" do + simulate_platform "java" + + build_git "only_java", "1.0" do |s| + s.platform = "java" + end + + build_git "only_java", "1.1" do |s| + s.platform = "java" + s.write "only_java1-0.gemspec", File.read("#{lib_path("only_java-1.0-java")}/only_java.gemspec") + end + + install_gemfile <<-G + platforms :jruby do + gem "only_java", "1.2", :git => "#{lib_path("only_java-1.1-java")}" + end + G + + expect(out).to include("Source contains 'only_java' at: 1.0 java, 1.1 java") end it "still works after moving the application directory" do diff --git a/spec/support/builders.rb b/spec/support/builders.rb index 3a18cbea77..c43e410c88 100644 --- a/spec/support/builders.rb +++ b/spec/support/builders.rb @@ -103,8 +103,14 @@ module Spec s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 x86-darwin-100'" end - build_gem "only_java" do |s| + build_gem "only_java", "1.0" do |s| s.platform = "java" + s.write "lib/only_java.rb", "ONLY_JAVA = '1.0.0 JAVA'" + end + + build_gem "only_java", "1.1" do |s| + s.platform = "java" + s.write "lib/only_java.rb", "ONLY_JAVA = '1.1.0 JAVA'" end build_gem "nokogiri", "1.4.2" |