summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Wen <jrw2175@columbia.edu>2016-02-22 00:20:31 -0500
committerJames Wen <jrw2175@columbia.edu>2016-02-22 00:21:06 -0500
commit2ffae987ae0a91305509365d6192c4d473245912 (patch)
treefc4c2743907711667798d8a0f77123d0aa8a3522
parent1328c77a2ae4ac68828f08fad4ff3876c344fc61 (diff)
downloadbundler-2ffae987ae0a91305509365d6192c4d473245912.tar.gz
Add platform info to error message for different platform in gemspec than Gemfile.lock
- Closes #4259
-rw-r--r--lib/bundler/resolver.rb19
-rw-r--r--spec/install/gemfile/git_spec.rb18
-rw-r--r--spec/support/builders.rb1
3 files changed, 33 insertions, 5 deletions
diff --git a/lib/bundler/resolver.rb b/lib/bundler/resolver.rb
index d22ab34e98..442c72c7f2 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..aa95bad375 100644
--- a/spec/install/gemfile/git_spec.rb
+++ b/spec/install/gemfile/git_spec.rb
@@ -82,7 +82,23 @@ 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 "still works after moving the application directory" do
diff --git a/spec/support/builders.rb b/spec/support/builders.rb
index 3a18cbea77..95a41d6eab 100644
--- a/spec/support/builders.rb
+++ b/spec/support/builders.rb
@@ -105,6 +105,7 @@ module Spec
build_gem "only_java" do |s|
s.platform = "java"
+ s.write "lib/only_java.rb", "ONLY_JAVA = '1.0.0 JAVA'"
end
build_gem "nokogiri", "1.4.2"