summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/bundler/installer.rb19
-rw-r--r--spec/install/gems/resolving_spec.rb23
2 files changed, 39 insertions, 3 deletions
diff --git a/lib/bundler/installer.rb b/lib/bundler/installer.rb
index fcf68928e4..c19b2edbc0 100644
--- a/lib/bundler/installer.rb
+++ b/lib/bundler/installer.rb
@@ -68,6 +68,7 @@ module Bundler
end
resolve_if_need(options)
+ ensure_specs_are_compatible!
install(options)
lock unless Bundler.settings[:frozen]
@@ -156,6 +157,24 @@ module Bundler
install_in_parallel jobs, options[:standalone], force
end
+ def ensure_specs_are_compatible!
+ system_ruby = Bundler::RubyVersion.system
+ rubygems_version = Gem::Version.create(Gem::VERSION)
+ specs.each do |spec|
+ if required_ruby_version = spec.required_ruby_version
+ unless required_ruby_version.satisfied_by?(system_ruby.gem_version)
+ raise InstallError, "#{spec.full_name} requires ruby version #{required_ruby_version}, " \
+ "which is incompatible with the current version, #{system_ruby}"
+ end
+ end
+ next unless required_rubygems_version = spec.required_rubygems_version
+ unless required_rubygems_version.satisfied_by?(rubygems_version)
+ raise InstallError, "#{spec.full_name} requires rubygems version #{required_rubygems_version}, " \
+ "which is incompatible with the current version, #{rubygems_version}"
+ end
+ end
+ end
+
def can_install_in_parallel?
if Bundler.rubygems.provides?(">= 2.1.0")
true
diff --git a/spec/install/gems/resolving_spec.rb b/spec/install/gems/resolving_spec.rb
index 49d160063d..74acf9a918 100644
--- a/spec/install/gems/resolving_spec.rb
+++ b/spec/install/gems/resolving_spec.rb
@@ -105,20 +105,37 @@ describe "bundle install with gem sources" do
describe "when some gems require a different version of ruby" do
it "does not try to install those gems" do
- pending "waiting for a rubygems index that includes ruby version"
-
update_repo gem_repo1 do
build_gem "require_ruby" do |s|
s.required_ruby_version = "> 9000"
end
end
- install_gemfile <<-G
+ install_gemfile <<-G, :artifice => "compact_index"
source "file://#{gem_repo1}"
gem 'require_ruby'
G
expect(out).to_not include("Gem::InstallError: require_ruby requires Ruby version > 9000")
+ expect(out).to include("require_ruby-1.0 requires ruby version > 9000, which is incompatible with the current version, #{Bundler::RubyVersion.system}")
+ end
+ end
+
+ describe "when some gems require a different version of rubygems" do
+ it "does not try to install those gems" do
+ update_repo gem_repo1 do
+ build_gem "require_rubygems" do |s|
+ s.required_rubygems_version = "> 9000"
+ end
+ end
+
+ install_gemfile <<-G, :artifice => "compact_index"
+ source "file://#{gem_repo1}"
+ gem 'require_rubygems'
+ G
+
+ expect(out).to_not include("Gem::InstallError: require_rubygems requires RubyGems version > 9000")
+ expect(out).to include("require_rubygems-1.0 requires rubygems version > 9000, which is incompatible with the current version, #{Gem::VERSION}")
end
end
end