Skip to content

Commit

Permalink
[rubygems/rubygems] Remove no longer necessary workaround for old Rub…
Browse files Browse the repository at this point in the history
  • Loading branch information
deivid-rodriguez authored and hsbt committed Nov 27, 2023
1 parent 67ee91a commit 60803e1
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 34 deletions.
4 changes: 2 additions & 2 deletions spec/bundler/commands/config_spec.rb
Expand Up @@ -443,15 +443,15 @@
expect(err).to be_empty

ruby(<<~RUBY)
require "#{entrypoint}"
require "bundler"
print Bundler.settings.mirror_for("https://rails-assets.org")
RUBY
expect(out).to eq("https://rails-assets.org/")
expect(err).to be_empty

bundle "config set mirror.all http://localhost:9293"
ruby(<<~RUBY)
require "#{entrypoint}"
require "bundler"
print Bundler.settings.mirror_for("https://rails-assets.org")
RUBY
expect(out).to eq("http://localhost:9293/")
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/install/gemfile/groups_spec.rb
Expand Up @@ -349,7 +349,7 @@
G

ruby <<-R
require "#{entrypoint}"
require "bundler"
Bundler.setup :default
Bundler.require :default
puts RACK
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/lock/lockfile_spec.rb
Expand Up @@ -1733,7 +1733,7 @@ def set_lockfile_mtime_to_known_value

expect do
ruby <<-RUBY
require '#{entrypoint}'
require 'bundler'
Bundler.setup
RUBY
end.not_to change { File.mtime(bundled_app_lock) }
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/other/major_deprecation_spec.rb
Expand Up @@ -503,7 +503,7 @@
G

ruby <<-RUBY
require '#{entrypoint}'
require 'bundler'
Bundler.setup
Bundler.setup
Expand Down
4 changes: 2 additions & 2 deletions spec/bundler/realworld/double_check_spec.rb
Expand Up @@ -25,9 +25,9 @@
RUBY

cmd = <<-RUBY
require "#{entrypoint}"
require "bundler"
require "#{spec_dir}/support/artifice/vcr"
require "#{entrypoint}/inline"
require "bundler/inline"
gemfile(true) do
source "https://rubygems.org"
gem "rails", path: "."
Expand Down
16 changes: 8 additions & 8 deletions spec/bundler/runtime/inline_spec.rb
Expand Up @@ -2,7 +2,7 @@

RSpec.describe "bundler/inline#gemfile" do
def script(code, options = {})
requires = ["#{entrypoint}/inline"]
requires = ["bundler/inline"]
requires.unshift "#{spec_dir}/support/artifice/" + options.delete(:artifice) if options.key?(:artifice)
requires = requires.map {|r| "require '#{r}'" }.join("\n")
ruby("#{requires}\n\n" + code, options)
Expand Down Expand Up @@ -95,7 +95,7 @@ def script(code, options = {})

it "lets me use my own ui object" do
script <<-RUBY, :artifice => "endpoint"
require '#{entrypoint}'
require 'bundler'
class MyBundlerUI < Bundler::UI::Shell
def confirm(msg, newline = nil)
puts "CONFIRMED!"
Expand All @@ -114,7 +114,7 @@ def confirm(msg, newline = nil)

it "has an option for quiet installation" do
script <<-RUBY, :artifice => "endpoint"
require '#{entrypoint}/inline'
require 'bundler/inline'
gemfile(true, :quiet => true) do
source "https://notaserver.com"
Expand All @@ -140,7 +140,7 @@ def confirm(msg, newline = nil)

it "does not mutate the option argument" do
script <<-RUBY
require '#{entrypoint}'
require 'bundler'
options = { :ui => Bundler::UI::Shell.new }
gemfile(false, options) do
source "#{file_uri_for(gem_repo1)}"
Expand Down Expand Up @@ -259,7 +259,7 @@ def confirm(msg, newline = nil)
system_gems "rack-1.0.0"

script <<-RUBY
require '#{entrypoint}'
require 'bundler'
ui = Bundler::UI::Shell.new
ui.level = "confirm"
Expand All @@ -279,7 +279,7 @@ def confirm(msg, newline = nil)
system_gems "rack-1.0.0"

script <<-RUBY
require '#{entrypoint}'
require 'bundler'
ui = Bundler::UI::Shell.new
ui.level = "confirm"
gemfile(true, ui: ui) do
Expand All @@ -302,7 +302,7 @@ def confirm(msg, newline = nil)
system_gems "rack-1.0.0"

script <<-RUBY
require '#{entrypoint}'
require 'bundler'
ui = Bundler::UI::Shell.new
ui.level = "confirm"
gemfile(true, ui: ui) do
Expand Down Expand Up @@ -339,7 +339,7 @@ def confirm(msg, newline = nil)
end

script <<-RUBY
require '#{entrypoint}'
require 'bundler'
ui = Bundler::UI::Shell.new
ui.level = "confirm"
gemfile(true, ui: ui) do
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/runtime/load_spec.rb
Expand Up @@ -82,7 +82,7 @@
G

ruby <<-RUBY
require "#{entrypoint}"
require "bundler"
Bundler.setup :default
Bundler.require :default
puts RACK
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/runtime/platform_spec.rb
Expand Up @@ -22,7 +22,7 @@

ruby <<-R
begin
require '#{entrypoint}'
require 'bundler'
Bundler.ui.silence { Bundler.setup }
rescue Bundler::GemNotFound => e
puts "WIN"
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/runtime/require_spec.rb
Expand Up @@ -199,7 +199,7 @@
G

cmd = <<-RUBY
require '#{entrypoint}'
require 'bundler'
Bundler.require
RUBY
ruby(cmd)
Expand Down
12 changes: 6 additions & 6 deletions spec/bundler/runtime/setup_spec.rb
Expand Up @@ -194,7 +194,7 @@ def clean_load_path(lp)
G

ruby <<-R
require '#{entrypoint}'
require 'bundler'
begin
Bundler.setup
Expand Down Expand Up @@ -441,7 +441,7 @@ def clean_load_path(lp)
break_git!

ruby <<-R
require "#{entrypoint}"
require "bundler"
begin
Bundler.setup
Expand Down Expand Up @@ -1187,7 +1187,7 @@ def lock_with(bundler_version = nil)
context "is not present" do
it "does not change the lock" do
lockfile lock_with(nil)
ruby "require '#{entrypoint}/setup'"
ruby "require 'bundler/setup'"
expect(lockfile).to eq lock_with(nil)
end
end
Expand All @@ -1206,7 +1206,7 @@ def lock_with(bundler_version = nil)
it "does not change the lock" do
system_gems "bundler-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")
end
end
Expand Down Expand Up @@ -1304,7 +1304,7 @@ def lock_with(ruby_version = nil)
bundle :install

ruby <<-RUBY
require '#{entrypoint}/setup'
require 'bundler/setup'
puts defined?(::Digest) ? "Digest defined" : "Digest undefined"
require 'digest'
RUBY
Expand All @@ -1314,7 +1314,7 @@ def lock_with(ruby_version = nil)
it "does not load Psych" do
gemfile "source \"#{file_uri_for(gem_repo1)}\""
ruby <<-RUBY
require '#{entrypoint}/setup'
require 'bundler/setup'
puts defined?(Psych::VERSION) ? Psych::VERSION : "undefined"
require 'psych'
puts Psych::VERSION
Expand Down
2 changes: 1 addition & 1 deletion spec/bundler/support/helpers.rb
Expand Up @@ -60,7 +60,7 @@ def exitstatus
def run(cmd, *args)
opts = args.last.is_a?(Hash) ? args.pop : {}
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)
end

Expand Down
7 changes: 0 additions & 7 deletions spec/bundler/support/path.rb
Expand Up @@ -225,13 +225,6 @@ def lib_dir
root.join("lib")
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)
home ".bundle", "plugin", "gems", *args
end
Expand Down
3 changes: 1 addition & 2 deletions spec/bundler/support/rubygems_version_manager.rb
Expand Up @@ -30,11 +30,10 @@ def assert_system_features_not_loaded!
rubygems_default_path = rubygems_path + "/defaults"

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|
(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

errors = if bad_loaded_features.any?
Expand Down

0 comments on commit 60803e1

Please sign in to comment.