[rubygems/rubygems] Drop support for Ruby 2.6 and Ruby 2.7 in Bundler

https://github.com/rubygems/rubygems/commit/93619c97ff
This commit is contained in:
David Rodríguez 2023-10-26 22:12:02 +02:00 committed by Hiroshi SHIBATA
parent 54511303a4
commit 50482cd1e5
24 changed files with 35 additions and 106 deletions

View File

@ -29,8 +29,8 @@ Gem::Specification.new do |s|
"source_code_uri" => "https://github.com/rubygems/rubygems/tree/master/bundler", "source_code_uri" => "https://github.com/rubygems/rubygems/tree/master/bundler",
} }
s.required_ruby_version = ">= 2.6.0" s.required_ruby_version = ">= 3.0.0"
s.required_rubygems_version = ">= 3.0.1" s.required_rubygems_version = ">= 3.1.2"
s.files = Dir.glob("lib/bundler{.rb,/**/*}", File::FNM_DOTMATCH).reject {|f| File.directory?(f) } s.files = Dir.glob("lib/bundler{.rb,/**/*}", File::FNM_DOTMATCH).reject {|f| File.directory?(f) }

View File

@ -46,7 +46,7 @@ module Bundler
@gemfile = expanded_gemfile_path @gemfile = expanded_gemfile_path
@gemfiles << expanded_gemfile_path @gemfiles << expanded_gemfile_path
contents ||= Bundler.read_file(@gemfile.to_s) contents ||= Bundler.read_file(@gemfile.to_s)
instance_eval(contents.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" }, gemfile.to_s, 1) instance_eval(contents.dup, gemfile.to_s, 1)
rescue Exception => e # rubocop:disable Lint/RescueException rescue Exception => e # rubocop:disable Lint/RescueException
message = "There was an error " \ message = "There was an error " \
"#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \ "#{e.is_a?(GemfileEvalError) ? "evaluating" : "parsing"} " \

View File

@ -46,7 +46,7 @@ module Gem
def full_gem_path def full_gem_path
if source.respond_to?(:root) if source.respond_to?(:root)
Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" } Pathname.new(loaded_from).dirname.expand_path(source.root).to_s
else else
rg_full_gem_path rg_full_gem_path
end end
@ -94,7 +94,7 @@ module Gem
rg_missing_extensions? rg_missing_extensions?
end end
remove_method :gem_dir if instance_methods(false).include?(:gem_dir) remove_method :gem_dir
def gem_dir def gem_dir
full_gem_path full_gem_path
end end
@ -135,17 +135,6 @@ module Gem
gemfile gemfile
end end
# Backfill missing YAML require when not defined. Fixed since 3.1.0.pre1.
module YamlBackfiller
def to_yaml(opts = {})
Gem.load_yaml unless defined?(::YAML)
super(opts)
end
end
prepend YamlBackfiller
def nondevelopment_dependencies def nondevelopment_dependencies
dependencies - development_dependencies dependencies - development_dependencies
end end
@ -382,9 +371,7 @@ module Gem
require "rubygems/util" require "rubygems/util"
Util.singleton_class.module_eval do Util.singleton_class.module_eval do
if Util.singleton_methods.include?(:glob_files_in_dir) # since 3.0.0.beta.2
remove_method :glob_files_in_dir remove_method :glob_files_in_dir
end
def glob_files_in_dir(glob, base_path) def glob_files_in_dir(glob, base_path)
Dir.glob(glob, :base => base_path).map! {|f| File.expand_path(f, base_path) } Dir.glob(glob, :base => base_path).map! {|f| File.expand_path(f, base_path) }

View File

@ -13,13 +13,13 @@ module Bundler
def root def root
gemfile = find_gemfile gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path.parent Pathname.new(gemfile).expand_path.parent
end end
def default_gemfile def default_gemfile
gemfile = find_gemfile gemfile = find_gemfile
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
Pathname.new(gemfile).tap {|x| x.untaint if RUBY_VERSION < "2.7" }.expand_path Pathname.new(gemfile).expand_path
end end
def default_lockfile def default_lockfile
@ -28,7 +28,7 @@ module Bundler
case gemfile.basename.to_s case gemfile.basename.to_s
when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked")) when "gems.rb" then Pathname.new(gemfile.sub(/.rb$/, ".locked"))
else Pathname.new("#{gemfile}.lock") else Pathname.new("#{gemfile}.lock")
end.tap {|x| x.untaint if RUBY_VERSION < "2.7" } end
end end
def default_bundle_dir def default_bundle_dir
@ -100,7 +100,7 @@ module Bundler
# #
# @see {Bundler::PermissionError} # @see {Bundler::PermissionError}
def filesystem_access(path, action = :write, &block) def filesystem_access(path, action = :write, &block)
yield(path.dup.tap {|x| x.untaint if RUBY_VERSION < "2.7" }) yield(path.dup)
rescue Errno::EACCES rescue Errno::EACCES
raise PermissionError.new(path, action) raise PermissionError.new(path, action)
rescue Errno::EAGAIN rescue Errno::EAGAIN
@ -250,7 +250,7 @@ module Bundler
def search_up(*names) def search_up(*names)
previous = nil previous = nil
current = File.expand_path(SharedHelpers.pwd).tap {|x| x.untaint if RUBY_VERSION < "2.7" } current = File.expand_path(SharedHelpers.pwd)
until !File.directory?(current) || current == previous until !File.directory?(current) || current == previous
if ENV["BUNDLER_SPEC_RUN"] if ENV["BUNDLER_SPEC_RUN"]
@ -299,7 +299,7 @@ module Bundler
Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file Bundler::SharedHelpers.set_env "BUNDLE_BIN_PATH", exe_file
Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile.to_s Bundler::SharedHelpers.set_env "BUNDLE_GEMFILE", find_gemfile.to_s
Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION Bundler::SharedHelpers.set_env "BUNDLER_VERSION", Bundler::VERSION
Bundler::SharedHelpers.set_env "BUNDLER_SETUP", File.expand_path("setup", __dir__) unless RUBY_VERSION < "2.7" Bundler::SharedHelpers.set_env "BUNDLER_SETUP", File.expand_path("setup", __dir__)
end end
def set_path def set_path

View File

@ -360,7 +360,7 @@ module Bundler
def load_gemspec(file) def load_gemspec(file)
stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent) stub = Gem::StubSpecification.gemspec_stub(file, install_path.parent, install_path.parent)
stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s.tap {|x| x.untaint if RUBY_VERSION < "2.7" } stub.full_gem_path = Pathname.new(file).dirname.expand_path(root).to_s
StubSpecification.from_stub(stub) StubSpecification.from_stub(stub)
end end

View File

@ -15,15 +15,6 @@ end
require "bundler" require "bundler"
if Gem.rubygems_version < Gem::Version.new("3.2.3") && Gem.ruby_version < Gem::Version.new("2.7.a") && !ENV["BUNDLER_NO_OLD_RUBYGEMS_WARNING"]
Bundler.ui.warn \
"Your RubyGems version (#{Gem::VERSION}) has a bug that prevents " \
"`required_ruby_version` from working for Bundler. Any scripts that use " \
"`gem install bundler` will break as soon as Bundler drops support for " \
"your Ruby version. Please upgrade RubyGems to avoid future breakage " \
"and silence this warning by running `gem update --system 3.2.3`"
end
require "bundler/friendly_errors" require "bundler/friendly_errors"
Bundler.with_friendly_errors do Bundler.with_friendly_errors do

View File

@ -248,8 +248,6 @@ RSpec.describe Bundler::SharedHelpers do
shared_examples_for "ENV['BUNDLER_SETUP'] gets set correctly" do shared_examples_for "ENV['BUNDLER_SETUP'] gets set correctly" do
it "ensures bundler/setup is set in ENV['BUNDLER_SETUP']" do it "ensures bundler/setup is set in ENV['BUNDLER_SETUP']" do
skip "Does not play well with DidYouMean being a bundled gem instead of a default gem in Ruby 2.6" if RUBY_VERSION < "2.7"
subject.set_bundle_environment subject.set_bundle_environment
expect(ENV["BUNDLER_SETUP"]).to eq("#{source_lib_dir}/bundler/setup") expect(ENV["BUNDLER_SETUP"]).to eq("#{source_lib_dir}/bundler/setup")
end end

View File

@ -8,6 +8,6 @@ Gem::Specification.new do |s|
s.version = "1.0.0" s.version = "1.0.0"
s.loaded_from = __FILE__ s.loaded_from = __FILE__
s.extensions = "ext/foo" s.extensions = "ext/foo"
s.required_ruby_version = ">= 2.6.0" s.required_ruby_version = ">= 3.0.0"
end end
# rubocop:enable Style/FrozenStringLiteralComment # rubocop:enable Style/FrozenStringLiteralComment

View File

@ -626,8 +626,6 @@ RSpec.describe "bundle clean" do
end end
it "when using --force, it doesn't remove default gem binaries", :realworld do it "when using --force, it doesn't remove default gem binaries", :realworld do
skip "does not work on old rubies because the realworld gems that need to be installed don't support them" if RUBY_VERSION < "2.7.0"
skip "does not work on rubygems versions where `--install_dir` doesn't respect --default" unless Gem::Installer.for_spec(loaded_gemspec, :install_dir => "/foo").default_spec_file == "/foo/specifications/default/bundler-#{Bundler::VERSION}.gemspec" # Since rubygems 3.2.0.rc.2 skip "does not work on rubygems versions where `--install_dir` doesn't respect --default" unless Gem::Installer.for_spec(loaded_gemspec, :install_dir => "/foo").default_spec_file == "/foo/specifications/default/bundler-#{Bundler::VERSION}.gemspec" # Since rubygems 3.2.0.rc.2
default_irb_version = ruby "gem 'irb', '< 999999'; require 'irb'; puts IRB::VERSION", :raise_on_error => false default_irb_version = ruby "gem 'irb', '< 999999'; require 'irb'; puts IRB::VERSION", :raise_on_error => false

View File

@ -616,7 +616,7 @@ RSpec.describe "bundle exec" do
end end
it "loads the correct optparse when `auto_install` is set, and optparse is a dependency" do it "loads the correct optparse when `auto_install` is set, and optparse is a dependency" do
if Gem.ruby_version >= Gem::Version.new("3.0.0") && Gem.rubygems_version < Gem::Version.new("3.3.0.a") if Gem.rubygems_version < Gem::Version.new("3.3.0.a")
skip "optparse is a default gem, and rubygems loads it during install" skip "optparse is a default gem, and rubygems loads it during install"
end end

View File

@ -1582,11 +1582,9 @@ RSpec.describe "bundle install with gems on multiple sources" do
end end
G G
simulate_bundler_version_when_missing_prerelease_default_gem_activation do
ruby <<~R, :raise_on_error => false ruby <<~R, :raise_on_error => false
require 'bundler/setup' require 'bundler/setup'
R R
end
expect(last_command).to be_failure expect(last_command).to be_failure
expect(err).to include("Could not find gem 'example' in locally installed gems.") expect(err).to include("Could not find gem 'example' in locally installed gems.")

View File

@ -416,7 +416,7 @@ The checksum of /versions does not match the checksum provided by the server! So
FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")] FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
end end
install_gemfile <<-G, :artifice => "compact_index_extra_missing", :env => env_for_missing_prerelease_default_gem_activation install_gemfile <<-G, :artifice => "compact_index_extra_missing"
source "#{source_uri}" source "#{source_uri}"
source "#{source_uri}/extra" do source "#{source_uri}/extra" do
gem "back_deps" gem "back_deps"
@ -436,7 +436,7 @@ The checksum of /versions does not match the checksum provided by the server! So
FileUtils.rm_rf Dir[gem_repo4("gems/foo-*.gem")] FileUtils.rm_rf Dir[gem_repo4("gems/foo-*.gem")]
end end
install_gemfile <<-G, :artifice => "compact_index_extra_api_missing", :env => env_for_missing_prerelease_default_gem_activation install_gemfile <<-G, :artifice => "compact_index_extra_api_missing"
source "#{source_uri}" source "#{source_uri}"
source "#{source_uri}/extra" do source "#{source_uri}/extra" do
gem "back_deps" gem "back_deps"

View File

@ -369,7 +369,7 @@ RSpec.describe "gemcutter's dependency API" do
FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")] FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
end end
install_gemfile <<-G, :artifice => "endpoint_extra_missing", :env => env_for_missing_prerelease_default_gem_activation install_gemfile <<-G, :artifice => "endpoint_extra_missing"
source "#{source_uri}" source "#{source_uri}"
source "#{source_uri}/extra" source "#{source_uri}/extra"
gem "back_deps" gem "back_deps"
@ -388,7 +388,7 @@ RSpec.describe "gemcutter's dependency API" do
FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")] FileUtils.rm_rf Dir[gem_repo2("gems/foo-*.gem")]
end end
install_gemfile <<-G, :artifice => "endpoint_extra_missing", :env => env_for_missing_prerelease_default_gem_activation install_gemfile <<-G, :artifice => "endpoint_extra_missing"
source "#{source_uri}" source "#{source_uri}"
source "#{source_uri}/extra" do source "#{source_uri}/extra" do
gem "back_deps" gem "back_deps"

View File

@ -142,7 +142,6 @@ RSpec.shared_examples "bundle install --standalone" do
describe "with default gems and a lockfile", :ruby_repo do describe "with default gems and a lockfile", :ruby_repo do
before do before do
skip "does not work on rubygems versions where `--install_dir` doesn't respect --default" unless Gem::Installer.for_spec(loaded_gemspec, :install_dir => "/foo").default_spec_file == "/foo/specifications/default/bundler-#{Bundler::VERSION}.gemspec" # Since rubygems 3.2.0.rc.2 skip "does not work on rubygems versions where `--install_dir` doesn't respect --default" unless Gem::Installer.for_spec(loaded_gemspec, :install_dir => "/foo").default_spec_file == "/foo/specifications/default/bundler-#{Bundler::VERSION}.gemspec" # Since rubygems 3.2.0.rc.2
skip "does not work on old rubies because the realworld gems that need to be installed don't support them" if RUBY_VERSION < "2.7.0"
realworld_system_gems "tsort --version 0.1.0" realworld_system_gems "tsort --version 0.1.0"

View File

@ -193,10 +193,8 @@ RSpec.describe "global gem caching" do
bundle :install, :artifice => "compact_index_no_gem", :dir => bundled_app2 bundle :install, :artifice => "compact_index_no_gem", :dir => bundled_app2
# activesupport is installed and both are in the global cache # activesupport is installed and both are in the global cache
simulate_bundler_version_when_missing_prerelease_default_gem_activation do
expect(the_bundle).not_to include_gems "rack 1.0.0", :dir => bundled_app2 expect(the_bundle).not_to include_gems "rack 1.0.0", :dir => bundled_app2
expect(the_bundle).to include_gems "activesupport 2.3.5", :dir => bundled_app2 expect(the_bundle).to include_gems "activesupport 2.3.5", :dir => bundled_app2
end
expect(source_global_cache("rack-1.0.0.gem")).to exist expect(source_global_cache("rack-1.0.0.gem")).to exist
expect(source_global_cache("activesupport-2.3.5.gem")).to exist expect(source_global_cache("activesupport-2.3.5.gem")).to exist

View File

@ -1712,11 +1712,9 @@ RSpec.describe "the lockfile format" do
expect { bundle "update", :all => true }.to change { File.mtime(bundled_app_lock) } expect { bundle "update", :all => true }.to change { File.mtime(bundled_app_lock) }
expect(File.read(bundled_app_lock)).to match("\r\n") expect(File.read(bundled_app_lock)).to match("\r\n")
simulate_bundler_version_when_missing_prerelease_default_gem_activation do
expect(the_bundle).to include_gems "rack 1.2" expect(the_bundle).to include_gems "rack 1.2"
end end
end end
end
context "when nothing changes" do context "when nothing changes" do
it "preserves Gemfile.lock \\n line endings" do it "preserves Gemfile.lock \\n line endings" do

View File

@ -519,7 +519,7 @@ RSpec.describe "major deprecations" do
context "when `bundler/deployment` is required in a ruby script" do context "when `bundler/deployment` is required in a ruby script" do
before do before do
ruby(<<-RUBY, :env => env_for_missing_prerelease_default_gem_activation) ruby <<-RUBY
require 'bundler/deployment' require 'bundler/deployment'
RUBY RUBY
end end

View File

@ -82,7 +82,7 @@ RSpec.describe "Resolving platform craziness" do
should_resolve_as %w[foo-1.0.0-x64-mingw32] should_resolve_as %w[foo-1.0.0-x64-mingw32]
end end
describe "on a linux platform", :rubygems => ">= 3.1.0.pre.1" do describe "on a linux platform" do
# Ruby's platform is *-linux => platform's libc is glibc, so not musl # Ruby's platform is *-linux => platform's libc is glibc, so not musl
# Ruby's platform is *-linux-musl => platform's libc is musl, so not glibc # Ruby's platform is *-linux-musl => platform's libc is musl, so not glibc
# Gem's platform is *-linux => gem is glibc + maybe musl compatible # Gem's platform is *-linux => gem is glibc + maybe musl compatible

View File

@ -89,7 +89,7 @@ RSpec.describe "bundler/inline#gemfile" do
expect(out).to include("Installing activesupport") expect(out).to include("Installing activesupport")
err_lines = err.split("\n") err_lines = err.split("\n")
err_lines.reject! {|line| line =~ /\.rb:\d+: warning: / } unless RUBY_VERSION < "2.7" err_lines.reject! {|line| line =~ /\.rb:\d+: warning: / }
expect(err_lines).to be_empty expect(err_lines).to be_empty
end end
@ -595,8 +595,6 @@ RSpec.describe "bundler/inline#gemfile" do
dependency_installer_loads_fileutils = ruby "require 'rubygems/dependency_installer'; puts $LOADED_FEATURES.grep(/fileutils/)", :raise_on_error => false dependency_installer_loads_fileutils = ruby "require 'rubygems/dependency_installer'; puts $LOADED_FEATURES.grep(/fileutils/)", :raise_on_error => false
skip "does not work if rubygems/dependency_installer loads fileutils, which happens until rubygems 3.2.0" unless dependency_installer_loads_fileutils.empty? skip "does not work if rubygems/dependency_installer loads fileutils, which happens until rubygems 3.2.0" unless dependency_installer_loads_fileutils.empty?
skip "pathname does not install cleanly on this ruby" if RUBY_VERSION < "2.7.0"
Dir.mkdir tmp("path_without_gemfile") Dir.mkdir tmp("path_without_gemfile")
default_fileutils_version = ruby "gem 'fileutils', '< 999999'; require 'fileutils'; puts FileUtils::VERSION", :raise_on_error => false default_fileutils_version = ruby "gem 'fileutils', '< 999999'; require 'fileutils'; puts FileUtils::VERSION", :raise_on_error => false

View File

@ -1279,8 +1279,6 @@ end
describe "with gemified standard libraries" do describe "with gemified standard libraries" do
it "does not load Digest", :ruby_repo do it "does not load Digest", :ruby_repo do
skip "Only for Ruby 3.0+" unless RUBY_VERSION >= "3.0"
build_git "bar", :gemspec => false do |s| build_git "bar", :gemspec => false do |s|
s.write "lib/bar/version.rb", %(BAR_VERSION = '1.0') s.write "lib/bar/version.rb", %(BAR_VERSION = '1.0')
s.write "bar.gemspec", <<-G s.write "bar.gemspec", <<-G
@ -1339,9 +1337,7 @@ end
describe "default gem activation" do describe "default gem activation" do
let(:exemptions) do let(:exemptions) do
exempts = %w[did_you_mean bundler] exempts = %w[did_you_mean bundler uri pathname]
exempts << "uri" if Gem.ruby_version >= Gem::Version.new("2.7")
exempts << "pathname" if Gem.ruby_version >= Gem::Version.new("3.0")
exempts << "etc" if Gem.ruby_version < Gem::Version.new("3.2") && Gem.win_platform? exempts << "etc" if Gem.ruby_version < Gem::Version.new("3.2") && Gem.win_platform?
exempts << "set" unless Gem.rubygems_version >= Gem::Version.new("3.2.6") exempts << "set" unless Gem.rubygems_version >= Gem::Version.new("3.2.6")
exempts << "tsort" unless Gem.rubygems_version >= Gem::Version.new("3.2.31") exempts << "tsort" unless Gem.rubygems_version >= Gem::Version.new("3.2.31")

View File

@ -90,9 +90,7 @@ RSpec.describe "Bundler.with_env helpers" do
RUBY RUBY
setup_require = "-r#{lib_dir}/bundler/setup" setup_require = "-r#{lib_dir}/bundler/setup"
ENV["BUNDLER_ORIG_RUBYOPT"] = "-W2 #{setup_require} #{ENV["RUBYOPT"]}" ENV["BUNDLER_ORIG_RUBYOPT"] = "-W2 #{setup_require} #{ENV["RUBYOPT"]}"
simulate_bundler_version_when_missing_prerelease_default_gem_activation do
bundle_exec_ruby bundled_app("source.rb") bundle_exec_ruby bundled_app("source.rb")
end
expect(last_command.stdboth).not_to include(setup_require) expect(last_command.stdboth).not_to include(setup_require)
end end
@ -101,9 +99,7 @@ RSpec.describe "Bundler.with_env helpers" do
print #{modified_env}['RUBYOPT'] print #{modified_env}['RUBYOPT']
RUBY RUBY
ENV["BUNDLER_ORIG_RUBYOPT"] = "-W2 -rbundler/setup #{ENV["RUBYOPT"]}" ENV["BUNDLER_ORIG_RUBYOPT"] = "-W2 -rbundler/setup #{ENV["RUBYOPT"]}"
simulate_bundler_version_when_missing_prerelease_default_gem_activation do
bundle_exec_ruby bundled_app("source.rb") bundle_exec_ruby bundled_app("source.rb")
end
expect(last_command.stdboth).not_to include("-rbundler/setup") expect(last_command.stdboth).not_to include("-rbundler/setup")
end end

View File

@ -77,7 +77,6 @@ RSpec.configure do |config|
require_relative "support/rubygems_ext" require_relative "support/rubygems_ext"
Spec::Rubygems.test_setup Spec::Rubygems.test_setup
ENV["BUNDLER_SPEC_RUN"] = "true" ENV["BUNDLER_SPEC_RUN"] = "true"
ENV["BUNDLER_NO_OLD_RUBYGEMS_WARNING"] = "true"
ENV["BUNDLE_USER_CONFIG"] = ENV["BUNDLE_USER_CACHE"] = ENV["BUNDLE_USER_PLUGIN"] = nil ENV["BUNDLE_USER_CONFIG"] = ENV["BUNDLE_USER_CACHE"] = ENV["BUNDLE_USER_PLUGIN"] = nil
ENV["BUNDLE_APP_CONFIG"] = nil ENV["BUNDLE_APP_CONFIG"] = nil
ENV["BUNDLE_SILENCE_ROOT_WARNING"] = nil ENV["BUNDLE_SILENCE_ROOT_WARNING"] = nil

View File

@ -464,32 +464,12 @@ module Spec
old = ENV["BUNDLER_SPEC_WINDOWS"] old = ENV["BUNDLER_SPEC_WINDOWS"]
ENV["BUNDLER_SPEC_WINDOWS"] = "true" ENV["BUNDLER_SPEC_WINDOWS"] = "true"
simulate_platform platform do simulate_platform platform do
simulate_bundler_version_when_missing_prerelease_default_gem_activation do
yield yield
end end
end
ensure ensure
ENV["BUNDLER_SPEC_WINDOWS"] = old ENV["BUNDLER_SPEC_WINDOWS"] = old
end end
def simulate_bundler_version_when_missing_prerelease_default_gem_activation
return yield unless rubygems_version_failing_to_activate_bundler_prereleases
old = ENV["BUNDLER_VERSION"]
ENV["BUNDLER_VERSION"] = Bundler::VERSION
yield
ensure
ENV["BUNDLER_VERSION"] = old
end
def env_for_missing_prerelease_default_gem_activation
if rubygems_version_failing_to_activate_bundler_prereleases
{ "BUNDLER_VERSION" => Bundler::VERSION }
else
{}
end
end
def current_ruby_minor def current_ruby_minor
Gem.ruby_version.segments.tap {|s| s.delete_at(2) }.join(".") Gem.ruby_version.segments.tap {|s| s.delete_at(2) }.join(".")
end end
@ -508,12 +488,6 @@ module Spec
Gem.ruby_version.segments[0..1] Gem.ruby_version.segments[0..1]
end end
# versions not including
# https://github.com/rubygems/rubygems/commit/929e92d752baad3a08f3ac92eaec162cb96aedd1
def rubygems_version_failing_to_activate_bundler_prereleases
Gem.rubygems_version < Gem::Version.new("3.1.0.pre.1")
end
def revision_for(path) def revision_for(path)
sys_exec("git rev-parse HEAD", :dir => path).strip sys_exec("git rev-parse HEAD", :dir => path).strip
end end

View File

@ -42,8 +42,7 @@ module Spec
end end
def dev_gemfile def dev_gemfile
name = RUBY_VERSION.start_with?("2.6") ? "dev26_gems.rb" : "dev_gems.rb" @dev_gemfile ||= tool_dir.join("dev_gems.rb")
@dev_gemfile ||= tool_dir.join(name)
end end
def bindir def bindir
@ -292,11 +291,11 @@ module Spec
end end
def rubocop_gemfile_basename def rubocop_gemfile_basename
tool_dir.join(RUBY_VERSION.start_with?("2.6") ? "rubocop26_gems.rb" : "rubocop_gems.rb") tool_dir.join("rubocop_gems.rb")
end end
def standard_gemfile_basename def standard_gemfile_basename
tool_dir.join(RUBY_VERSION.start_with?("2.6") ? "standard26_gems.rb" : "standard_gems.rb") tool_dir.join("standard_gems.rb")
end end
def tool_dir def tool_dir