[rubygems/rubygems] Remove no longer necessary workaround for old RubyGems

https://github.com/rubygems/rubygems/commit/ed4eaefac0
This commit is contained in:
David Rodríguez 2023-11-23 22:06:19 +01:00 committed by Hiroshi SHIBATA
parent 67ee91a305
commit 60803e192e
13 changed files with 26 additions and 34 deletions

View File

@ -443,7 +443,7 @@ E
expect(err).to be_empty expect(err).to be_empty
ruby(<<~RUBY) ruby(<<~RUBY)
require "#{entrypoint}" require "bundler"
print Bundler.settings.mirror_for("https://rails-assets.org") print Bundler.settings.mirror_for("https://rails-assets.org")
RUBY RUBY
expect(out).to eq("https://rails-assets.org/") expect(out).to eq("https://rails-assets.org/")
@ -451,7 +451,7 @@ E
bundle "config set mirror.all http://localhost:9293" bundle "config set mirror.all http://localhost:9293"
ruby(<<~RUBY) ruby(<<~RUBY)
require "#{entrypoint}" require "bundler"
print Bundler.settings.mirror_for("https://rails-assets.org") print Bundler.settings.mirror_for("https://rails-assets.org")
RUBY RUBY
expect(out).to eq("http://localhost:9293/") expect(out).to eq("http://localhost:9293/")

View File

@ -349,7 +349,7 @@ RSpec.describe "bundle install with groups" do
G G
ruby <<-R ruby <<-R
require "#{entrypoint}" require "bundler"
Bundler.setup :default Bundler.setup :default
Bundler.require :default Bundler.require :default
puts RACK puts RACK

View File

@ -1733,7 +1733,7 @@ RSpec.describe "the lockfile format" do
expect do expect do
ruby <<-RUBY ruby <<-RUBY
require '#{entrypoint}' require 'bundler'
Bundler.setup Bundler.setup
RUBY RUBY
end.not_to change { File.mtime(bundled_app_lock) } end.not_to change { File.mtime(bundled_app_lock) }

View File

@ -503,7 +503,7 @@ RSpec.describe "major deprecations" do
G G
ruby <<-RUBY ruby <<-RUBY
require '#{entrypoint}' require 'bundler'
Bundler.setup Bundler.setup
Bundler.setup Bundler.setup

View File

@ -25,9 +25,9 @@ RSpec.describe "double checking sources", :realworld => true do
RUBY RUBY
cmd = <<-RUBY cmd = <<-RUBY
require "#{entrypoint}" require "bundler"
require "#{spec_dir}/support/artifice/vcr" require "#{spec_dir}/support/artifice/vcr"
require "#{entrypoint}/inline" require "bundler/inline"
gemfile(true) do gemfile(true) do
source "https://rubygems.org" source "https://rubygems.org"
gem "rails", path: "." gem "rails", path: "."

View File

@ -2,7 +2,7 @@
RSpec.describe "bundler/inline#gemfile" do RSpec.describe "bundler/inline#gemfile" do
def script(code, options = {}) def script(code, options = {})
requires = ["#{entrypoint}/inline"] requires = ["bundler/inline"]
requires.unshift "#{spec_dir}/support/artifice/" + options.delete(:artifice) if options.key?(:artifice) requires.unshift "#{spec_dir}/support/artifice/" + options.delete(:artifice) if options.key?(:artifice)
requires = requires.map {|r| "require '#{r}'" }.join("\n") requires = requires.map {|r| "require '#{r}'" }.join("\n")
ruby("#{requires}\n\n" + code, options) ruby("#{requires}\n\n" + code, options)
@ -95,7 +95,7 @@ RSpec.describe "bundler/inline#gemfile" do
it "lets me use my own ui object" do it "lets me use my own ui object" do
script <<-RUBY, :artifice => "endpoint" script <<-RUBY, :artifice => "endpoint"
require '#{entrypoint}' require 'bundler'
class MyBundlerUI < Bundler::UI::Shell class MyBundlerUI < Bundler::UI::Shell
def confirm(msg, newline = nil) def confirm(msg, newline = nil)
puts "CONFIRMED!" puts "CONFIRMED!"
@ -114,7 +114,7 @@ RSpec.describe "bundler/inline#gemfile" do
it "has an option for quiet installation" do it "has an option for quiet installation" do
script <<-RUBY, :artifice => "endpoint" script <<-RUBY, :artifice => "endpoint"
require '#{entrypoint}/inline' require 'bundler/inline'
gemfile(true, :quiet => true) do gemfile(true, :quiet => true) do
source "https://notaserver.com" source "https://notaserver.com"
@ -140,7 +140,7 @@ RSpec.describe "bundler/inline#gemfile" do
it "does not mutate the option argument" do it "does not mutate the option argument" do
script <<-RUBY script <<-RUBY
require '#{entrypoint}' require 'bundler'
options = { :ui => Bundler::UI::Shell.new } options = { :ui => Bundler::UI::Shell.new }
gemfile(false, options) do gemfile(false, options) do
source "#{file_uri_for(gem_repo1)}" source "#{file_uri_for(gem_repo1)}"
@ -259,7 +259,7 @@ RSpec.describe "bundler/inline#gemfile" do
system_gems "rack-1.0.0" system_gems "rack-1.0.0"
script <<-RUBY script <<-RUBY
require '#{entrypoint}' require 'bundler'
ui = Bundler::UI::Shell.new ui = Bundler::UI::Shell.new
ui.level = "confirm" ui.level = "confirm"
@ -279,7 +279,7 @@ RSpec.describe "bundler/inline#gemfile" do
system_gems "rack-1.0.0" system_gems "rack-1.0.0"
script <<-RUBY script <<-RUBY
require '#{entrypoint}' require 'bundler'
ui = Bundler::UI::Shell.new ui = Bundler::UI::Shell.new
ui.level = "confirm" ui.level = "confirm"
gemfile(true, ui: ui) do gemfile(true, ui: ui) do
@ -302,7 +302,7 @@ RSpec.describe "bundler/inline#gemfile" do
system_gems "rack-1.0.0" system_gems "rack-1.0.0"
script <<-RUBY script <<-RUBY
require '#{entrypoint}' require 'bundler'
ui = Bundler::UI::Shell.new ui = Bundler::UI::Shell.new
ui.level = "confirm" ui.level = "confirm"
gemfile(true, ui: ui) do gemfile(true, ui: ui) do
@ -339,7 +339,7 @@ RSpec.describe "bundler/inline#gemfile" do
end end
script <<-RUBY script <<-RUBY
require '#{entrypoint}' require 'bundler'
ui = Bundler::UI::Shell.new ui = Bundler::UI::Shell.new
ui.level = "confirm" ui.level = "confirm"
gemfile(true, ui: ui) do gemfile(true, ui: ui) do

View File

@ -82,7 +82,7 @@ RSpec.describe "Bundler.load" do
G G
ruby <<-RUBY ruby <<-RUBY
require "#{entrypoint}" require "bundler"
Bundler.setup :default Bundler.setup :default
Bundler.require :default Bundler.require :default
puts RACK puts RACK

View File

@ -22,7 +22,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do
ruby <<-R ruby <<-R
begin begin
require '#{entrypoint}' require 'bundler'
Bundler.ui.silence { Bundler.setup } Bundler.ui.silence { Bundler.setup }
rescue Bundler::GemNotFound => e rescue Bundler::GemNotFound => e
puts "WIN" puts "WIN"

View File

@ -199,7 +199,7 @@ RSpec.describe "Bundler.require" do
G G
cmd = <<-RUBY cmd = <<-RUBY
require '#{entrypoint}' require 'bundler'
Bundler.require Bundler.require
RUBY RUBY
ruby(cmd) ruby(cmd)

View File

@ -194,7 +194,7 @@ RSpec.describe "Bundler.setup" do
G G
ruby <<-R ruby <<-R
require '#{entrypoint}' require 'bundler'
begin begin
Bundler.setup Bundler.setup
@ -441,7 +441,7 @@ RSpec.describe "Bundler.setup" do
break_git! break_git!
ruby <<-R ruby <<-R
require "#{entrypoint}" require "bundler"
begin begin
Bundler.setup Bundler.setup
@ -1187,7 +1187,7 @@ end
context "is not present" do context "is not present" do
it "does not change the lock" do it "does not change the lock" do
lockfile lock_with(nil) lockfile lock_with(nil)
ruby "require '#{entrypoint}/setup'" ruby "require 'bundler/setup'"
expect(lockfile).to eq lock_with(nil) expect(lockfile).to eq lock_with(nil)
end end
end end
@ -1206,7 +1206,7 @@ end
it "does not change the lock" do it "does not change the lock" do
system_gems "bundler-1.10.1" system_gems "bundler-1.10.1"
lockfile lock_with("1.10.1") lockfile lock_with("1.10.1")
ruby "require '#{entrypoint}/setup'" ruby "require 'bundler/setup'"
expect(lockfile).to eq lock_with("1.10.1") expect(lockfile).to eq lock_with("1.10.1")
end end
end end
@ -1304,7 +1304,7 @@ end
bundle :install bundle :install
ruby <<-RUBY ruby <<-RUBY
require '#{entrypoint}/setup' require 'bundler/setup'
puts defined?(::Digest) ? "Digest defined" : "Digest undefined" puts defined?(::Digest) ? "Digest defined" : "Digest undefined"
require 'digest' require 'digest'
RUBY RUBY
@ -1314,7 +1314,7 @@ end
it "does not load Psych" do it "does not load Psych" do
gemfile "source \"#{file_uri_for(gem_repo1)}\"" gemfile "source \"#{file_uri_for(gem_repo1)}\""
ruby <<-RUBY ruby <<-RUBY
require '#{entrypoint}/setup' require 'bundler/setup'
puts defined?(Psych::VERSION) ? Psych::VERSION : "undefined" puts defined?(Psych::VERSION) ? Psych::VERSION : "undefined"
require 'psych' require 'psych'
puts Psych::VERSION puts Psych::VERSION

View File

@ -60,7 +60,7 @@ module Spec
def run(cmd, *args) def run(cmd, *args)
opts = args.last.is_a?(Hash) ? args.pop : {} opts = args.last.is_a?(Hash) ? args.pop : {}
groups = args.map(&:inspect).join(", ") groups = args.map(&:inspect).join(", ")
setup = "require '#{entrypoint}' ; Bundler.ui.silence { Bundler.setup(#{groups}) }" setup = "require 'bundler' ; Bundler.ui.silence { Bundler.setup(#{groups}) }"
ruby([setup, cmd].join(" ; "), opts) ruby([setup, cmd].join(" ; "), opts)
end end

View File

@ -225,13 +225,6 @@ module Spec
root.join("lib") root.join("lib")
end end
# Sometimes rubygems version under test does not include
# https://github.com/rubygems/rubygems/pull/2728 and will not always end up
# activating the current bundler. In that case, require bundler absolutely.
def entrypoint
Gem.rubygems_version < Gem::Version.new("3.1.a") ? "#{lib_dir}/bundler" : "bundler"
end
def global_plugin_gem(*args) def global_plugin_gem(*args)
home ".bundle", "plugin", "gems", *args home ".bundle", "plugin", "gems", *args
end end

View File

@ -30,11 +30,10 @@ class RubygemsVersionManager
rubygems_default_path = rubygems_path + "/defaults" rubygems_default_path = rubygems_path + "/defaults"
bundler_path = rubylibdir + "/bundler" bundler_path = rubylibdir + "/bundler"
bundler_exemptions = Gem.rubygems_version < Gem::Version.new("3.2.0") ? [bundler_path + "/errors.rb"] : []
bad_loaded_features = $LOADED_FEATURES.select do |loaded_feature| bad_loaded_features = $LOADED_FEATURES.select do |loaded_feature|
(loaded_feature.start_with?(rubygems_path) && !loaded_feature.start_with?(rubygems_default_path)) || (loaded_feature.start_with?(rubygems_path) && !loaded_feature.start_with?(rubygems_default_path)) ||
(loaded_feature.start_with?(bundler_path) && !bundler_exemptions.any? {|bundler_exemption| loaded_feature.start_with?(bundler_exemption) }) loaded_feature.start_with?(bundler_path)
end end
errors = if bad_loaded_features.any? errors = if bad_loaded_features.any?