summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2017-02-15 14:29:11 -0600
committerSamuel Giddins <segiddins@segiddins.me>2017-02-15 14:29:11 -0600
commitf3e44c1cdce8c6baad67af6323a9fd44c5f42411 (patch)
treedfd7860598bd9497f09947dbf15cb132e5d9890f
parent573d6f8ac64d604d71e78933117716b4ca77833f (diff)
downloadbundler-f3e44c1cdce8c6baad67af6323a9fd44c5f42411.tar.gz
[LazySpecification] Handle when the swapped platform-specfic spec has extra deps
-rw-r--r--lib/bundler/lazy_specification.rb9
-rw-r--r--spec/install/gemfile/platform_spec.rb26
-rw-r--r--spec/install/gemfile/specific_platform_spec.rb20
3 files changed, 54 insertions, 1 deletions
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index 7508347c32..b7dddcbf35 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -73,7 +73,14 @@ module Bundler
@specification = if source.is_a?(Source::Gemspec) && source.gemspec.name == name
source.gemspec.tap {|s| s.source = source }
else
- source.specs.search(search_object).last
+ search = source.specs.search(search_object).last
+ if search.platform != platform && !search.runtime_dependencies.-(dependencies.reject {|d| d.type == :development }).empty?
+ Bundler.ui.warn "Unable to use the platform-specific (#{search.platform}) version of #{name} (#{version}) " \
+ "because it has different dependencies from the #{platform} version. " \
+ "To use the platform-specific version of the gem, run `bundle config specific_platform true` and install again."
+ search = source.specs.search(self).last
+ end
+ search
end
end
diff --git a/spec/install/gemfile/platform_spec.rb b/spec/install/gemfile/platform_spec.rb
index 3b28a58ecc..c6eaec7ca6 100644
--- a/spec/install/gemfile/platform_spec.rb
+++ b/spec/install/gemfile/platform_spec.rb
@@ -88,6 +88,32 @@ RSpec.describe "bundle install across platforms" do
expect(the_bundle).to include_gems "nokogiri 1.4.2 JAVA", "weakling 0.0.3"
end
+ it "works with gems that have extra platform-specific runtime dependencies" do
+ simulate_platform x64_mac
+
+ update_repo2 do
+ build_gem "facter", "2.4.6"
+ build_gem "facter", "2.4.6" do |s|
+ s.platform = "universal-darwin"
+ s.add_runtime_dependency "CFPropertyList"
+ end
+ build_gem "CFPropertyList"
+ end
+
+ install_gemfile! <<-G
+ source "file://#{gem_repo2}"
+
+ gem "facter"
+ G
+
+ expect(out).to include "Unable to use the platform-specific (universal-darwin) version of facter (2.4.6) " \
+ "because it has different dependencies from the ruby version. " \
+ "To use the platform-specific version of the gem, run `bundle config specific_platform true` and install again."
+
+ expect(the_bundle).to include_gem "facter 2.4.6"
+ expect(the_bundle).not_to include_gem "CFPropertyList"
+ end
+
it "fetches gems again after changing the version of Ruby" do
gemfile <<-G
source "file://#{gem_repo1}"
diff --git a/spec/install/gemfile/specific_platform_spec.rb b/spec/install/gemfile/specific_platform_spec.rb
index 76ac976521..cc6c82c0ff 100644
--- a/spec/install/gemfile/specific_platform_spec.rb
+++ b/spec/install/gemfile/specific_platform_spec.rb
@@ -39,6 +39,13 @@ RSpec.describe "bundle install with specific_platform enabled" do
build_gem("google-protobuf", "3.0.0.alpha.2.0")
build_gem("google-protobuf", "3.0.0.alpha.1.1")
build_gem("google-protobuf", "3.0.0.alpha.1.0")
+
+ build_gem("facter", "2.4.6")
+ build_gem("facter", "2.4.6") do |s|
+ s.platform = "universal-darwin"
+ s.add_runtime_dependency "CFPropertyList"
+ end
+ build_gem("CFPropertyList")
end
end
@@ -67,6 +74,19 @@ RSpec.describe "bundle install with specific_platform enabled" do
to all(exist)
end
+ it "uses the platform-specific gem with extra dependencies" do
+ install_gemfile! <<-G
+ source "file:#{gem_repo2}"
+ gem "facter"
+ G
+
+ expect(the_bundle.locked_gems.platforms).to eq([pl("ruby"), pl("x86_64-darwin-15")])
+ expect(the_bundle).to include_gems("facter 2.4.6 universal-darwin", "CFPropertyList 1.0")
+ expect(the_bundle.locked_gems.specs.map(&:full_name)).to eq(["CFPropertyList-1.0",
+ "facter-2.4.6",
+ "facter-2.4.6-universal-darwin"])
+ end
+
context "when adding a platform via lock --add_platform" do
it "adds the foreign platform" do
install_gemfile!(google_protobuf)