summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Giddins <segiddins@segiddins.me>2016-08-18 18:33:52 -0500
committerSamuel Giddins <segiddins@segiddins.me>2016-08-25 11:16:58 -0500
commitbb7d870a70873e01619e115fc7abe2cd3cca90b3 (patch)
treee656da45af1b058e13452c560e55b1d3dc331a12
parenteab72a0819cd140d1c4d74134623e94fdf03f858 (diff)
downloadbundler-bb7d870a70873e01619e115fc7abe2cd3cca90b3.tar.gz
[Definition] Validate platform in addition to ruby
# Conflicts: # lib/bundler/cli/doctor.rb
-rw-r--r--lib/bundler.rb2
-rw-r--r--lib/bundler/cli/binstubs.rb2
-rw-r--r--lib/bundler/cli/cache.rb2
-rw-r--r--lib/bundler/cli/check.rb2
-rw-r--r--lib/bundler/cli/install.rb2
-rw-r--r--lib/bundler/cli/outdated.rb2
-rw-r--r--lib/bundler/cli/platform.rb2
-rw-r--r--lib/bundler/cli/show.rb2
-rw-r--r--lib/bundler/cli/update.rb2
-rw-r--r--lib/bundler/definition.rb21
-rw-r--r--lib/bundler/inline.rb2
11 files changed, 31 insertions, 10 deletions
diff --git a/lib/bundler.rb b/lib/bundler.rb
index 18b9e75253..8806ae01ef 100644
--- a/lib/bundler.rb
+++ b/lib/bundler.rb
@@ -91,7 +91,7 @@ module Bundler
# Return if all groups are already loaded
return @setup if defined?(@setup) && @setup
- definition.validate_ruby!
+ definition.validate_runtime!
SharedHelpers.print_major_deprecations!
diff --git a/lib/bundler/cli/binstubs.rb b/lib/bundler/cli/binstubs.rb
index f7a27b01bb..95103b7dd8 100644
--- a/lib/bundler/cli/binstubs.rb
+++ b/lib/bundler/cli/binstubs.rb
@@ -10,7 +10,7 @@ module Bundler
end
def run
- Bundler.definition.validate_ruby!
+ Bundler.definition.validate_runtime!
Bundler.settings[:bin] = options["path"] if options["path"]
Bundler.settings[:bin] = nil if options["path"] && options["path"].empty?
installer = Installer.new(Bundler.root, Bundler.definition)
diff --git a/lib/bundler/cli/cache.rb b/lib/bundler/cli/cache.rb
index c8c63e926c..5ba105a31d 100644
--- a/lib/bundler/cli/cache.rb
+++ b/lib/bundler/cli/cache.rb
@@ -7,7 +7,7 @@ module Bundler
end
def run
- Bundler.definition.validate_ruby!
+ Bundler.definition.validate_runtime!
Bundler.definition.resolve_with_cache!
setup_cache_all
Bundler.settings[:cache_all_platforms] = options["all-platforms"] if options.key?("all-platforms")
diff --git a/lib/bundler/cli/check.rb b/lib/bundler/cli/check.rb
index 738d40b622..3f504ff621 100644
--- a/lib/bundler/cli/check.rb
+++ b/lib/bundler/cli/check.rb
@@ -15,7 +15,7 @@ module Bundler
begin
definition = Bundler.definition
- definition.validate_ruby!
+ definition.validate_runtime!
not_installed = definition.missing_specs
rescue GemNotFound, VersionConflict
Bundler.ui.error "Bundler can't satisfy your Gemfile's dependencies."
diff --git a/lib/bundler/cli/install.rb b/lib/bundler/cli/install.rb
index 9802ea8036..f1632c9ee2 100644
--- a/lib/bundler/cli/install.rb
+++ b/lib/bundler/cli/install.rb
@@ -66,7 +66,7 @@ module Bundler
Plugin.gemfile_install(Bundler.default_gemfile) if Bundler.feature_flag.plugins?
definition = Bundler.definition
- definition.validate_ruby!
+ definition.validate_runtime!
installer = Installer.install(Bundler.root, definition, options)
Bundler.load.cache if Bundler.app_cache.exist? && !options["no-cache"] && !Bundler.settings[:frozen]
diff --git a/lib/bundler/cli/outdated.rb b/lib/bundler/cli/outdated.rb
index 09b2d71453..de71075522 100644
--- a/lib/bundler/cli/outdated.rb
+++ b/lib/bundler/cli/outdated.rb
@@ -18,7 +18,7 @@ module Bundler
Bundler::CLI::Common.select_spec(gem_name)
end
- Bundler.definition.validate_ruby!
+ Bundler.definition.validate_runtime!
current_specs = Bundler.ui.silence { Bundler.load.specs }
current_dependencies = {}
Bundler.ui.silence { Bundler.load.dependencies.each {|dep| current_dependencies[dep.name] = dep } }
diff --git a/lib/bundler/cli/platform.rb b/lib/bundler/cli/platform.rb
index b5f906bfd9..9fdab0a53c 100644
--- a/lib/bundler/cli/platform.rb
+++ b/lib/bundler/cli/platform.rb
@@ -29,7 +29,7 @@ module Bundler
output << "Your Gemfile specifies a Ruby version requirement:\n* #{ruby_version}"
begin
- Bundler.definition.validate_ruby!
+ Bundler.definition.validate_runtime!
output << "Your current platform satisfies the Ruby version requirement."
rescue RubyVersionMismatch => e
output << e.message
diff --git a/lib/bundler/cli/show.rb b/lib/bundler/cli/show.rb
index d67b086dd1..77e845a603 100644
--- a/lib/bundler/cli/show.rb
+++ b/lib/bundler/cli/show.rb
@@ -13,7 +13,7 @@ module Bundler
def run
Bundler.ui.silence do
- Bundler.definition.validate_ruby!
+ Bundler.definition.validate_runtime!
Bundler.load.lock
end
diff --git a/lib/bundler/cli/update.rb b/lib/bundler/cli/update.rb
index ea2a4b8d8f..5aac47bd09 100644
--- a/lib/bundler/cli/update.rb
+++ b/lib/bundler/cli/update.rb
@@ -57,7 +57,7 @@ module Bundler
# rubygems plugins sometimes hook into the gem install process
Gem.load_env_plugins if Gem.respond_to?(:load_env_plugins)
- Bundler.definition.validate_ruby!
+ Bundler.definition.validate_runtime!
Installer.install Bundler.root, Bundler.definition, opts
Bundler.load.cache if Bundler.app_cache.exist?
diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 8e9ec8b585..0cb6e7e399 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -468,6 +468,11 @@ module Bundler
raise ProductionError, msg if added.any? || deleted.any? || changed.any?
end
+ def validate_runtime!
+ validate_ruby!
+ validate_platforms!
+ end
+
def validate_ruby!
return unless ruby_version
@@ -493,6 +498,22 @@ module Bundler
end
end
+ # TODO: refactor this so that `match_platform` can be called with two platforms
+ DummyPlatform = Struct.new(:platform)
+ class DummyPlatform; include MatchPlatform; end
+ def validate_platforms!
+ return if @platforms.any? do |bundle_platform|
+ bundle_platform = DummyPlatform.new(bundle_platform)
+ Bundler.rubygems.platforms.any? do |local_platform|
+ bundle_platform.match_platform(local_platform)
+ end
+ end
+
+ raise ProductionError, "Your bundle only supports platforms #{@platforms.map(&:to_s)} " \
+ "but your local platforms are #{Bundler.rubygems.platforms.map(&:to_s)}, and " \
+ "there's no compatible match between those two lists."
+ end
+
def add_platform(platform)
@new_platform ||= !@platforms.include?(platform)
@platforms |= [platform]
diff --git a/lib/bundler/inline.rb b/lib/bundler/inline.rb
index af542f1e44..dec3be3e98 100644
--- a/lib/bundler/inline.rb
+++ b/lib/bundler/inline.rb
@@ -47,7 +47,7 @@ def gemfile(install = false, options = {}, &gemfile)
definition = builder.to_definition(nil, true)
def definition.lock(*); end
- definition.validate_ruby!
+ definition.validate_runtime!
missing_specs = proc do
begin