mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parent
bb6b9b4929
commit
a1c69991a5
2 changed files with 21 additions and 10 deletions
|
@ -31,7 +31,7 @@ m = Module.new do
|
||||||
bundler_version = a
|
bundler_version = a
|
||||||
end
|
end
|
||||||
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
next unless a =~ /\A--bundler(?:[= ](#{Gem::Version::VERSION_PATTERN}))?\z/
|
||||||
bundler_version = $1 || ">= 0.a"
|
bundler_version = $1
|
||||||
update_index = i
|
update_index = i
|
||||||
end
|
end
|
||||||
bundler_version
|
bundler_version
|
||||||
|
@ -63,27 +63,30 @@ m = Module.new do
|
||||||
def bundler_version
|
def bundler_version
|
||||||
@bundler_version ||=
|
@bundler_version ||=
|
||||||
env_var_version || cli_arg_version ||
|
env_var_version || cli_arg_version ||
|
||||||
lockfile_version || "#{Gem::Requirement.default}.a"
|
lockfile_version
|
||||||
|
end
|
||||||
|
|
||||||
|
def bundler_requirement
|
||||||
|
return "#{Gem::Requirement.default}.a" unless bundler_version
|
||||||
|
|
||||||
|
Gem::Version.new(bundler_version).approximate_recommendation
|
||||||
end
|
end
|
||||||
|
|
||||||
def load_bundler!
|
def load_bundler!
|
||||||
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
ENV["BUNDLE_GEMFILE"] ||= gemfile
|
||||||
|
|
||||||
activate_bundler(bundler_version)
|
activate_bundler(bundler_requirement)
|
||||||
end
|
end
|
||||||
|
|
||||||
def activate_bundler(bundler_version)
|
def activate_bundler(bundler_requirement)
|
||||||
if Gem::Version.correct?(bundler_version) && Gem::Version.new(bundler_version).release < Gem::Version.new("2.0")
|
|
||||||
bundler_version = "< 2"
|
|
||||||
end
|
|
||||||
gem_error = activation_error_handling do
|
gem_error = activation_error_handling do
|
||||||
gem "bundler", bundler_version
|
gem "bundler", bundler_requirement
|
||||||
end
|
end
|
||||||
return if gem_error.nil?
|
return if gem_error.nil?
|
||||||
require_error = activation_error_handling do
|
require_error = activation_error_handling do
|
||||||
require "bundler/version"
|
require "bundler/version"
|
||||||
end
|
end
|
||||||
return if require_error.nil? && Gem::Requirement.new(bundler_version).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
return if require_error.nil? && Gem::Requirement.new(bundler_requirement).satisfied_by?(Gem::Version.new(Bundler::VERSION))
|
||||||
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
warn "Activating bundler (#{bundler_version}) failed:\n#{gem_error.message}\n\nTo install the version of bundler this project requires, run `gem install bundler -v '#{bundler_version}'`"
|
||||||
exit 42
|
exit 42
|
||||||
end
|
end
|
||||||
|
|
|
@ -149,7 +149,7 @@ RSpec.describe "bundle binstubs <gem>" do
|
||||||
and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`")
|
and include("To install the version of bundler this project requires, run `gem install bundler -v '999.999.999'`")
|
||||||
end
|
end
|
||||||
|
|
||||||
it "runs the correct version of bundler when the version is older" do
|
it "runs the correct version of bundler when the version is older and a different major" do
|
||||||
simulate_bundler_version "55"
|
simulate_bundler_version "55"
|
||||||
lockfile lockfile.gsub(system_bundler_version, "44.0")
|
lockfile lockfile.gsub(system_bundler_version, "44.0")
|
||||||
sys_exec "#{bundled_app("bin/bundle")} install"
|
sys_exec "#{bundled_app("bin/bundle")} install"
|
||||||
|
@ -158,6 +158,14 @@ RSpec.describe "bundle binstubs <gem>" do
|
||||||
and include("To install the version of bundler this project requires, run `gem install bundler -v '44.0'`")
|
and include("To install the version of bundler this project requires, run `gem install bundler -v '44.0'`")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it "runs the available version of bundler when the version is older and the same major" do
|
||||||
|
simulate_bundler_version "55.1"
|
||||||
|
lockfile lockfile.gsub(system_bundler_version, "55.0")
|
||||||
|
sys_exec "#{bundled_app("bin/bundle")} install"
|
||||||
|
expect(exitstatus).not_to eq(42) if exitstatus
|
||||||
|
expect(err).not_to include("Activating bundler (55.0) failed:")
|
||||||
|
end
|
||||||
|
|
||||||
it "runs the correct version of bundler when the version is a pre-release" do
|
it "runs the correct version of bundler when the version is a pre-release" do
|
||||||
simulate_bundler_version "55"
|
simulate_bundler_version "55"
|
||||||
lockfile lockfile.gsub(system_bundler_version, "2.12.0.a")
|
lockfile lockfile.gsub(system_bundler_version, "2.12.0.a")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue