diff options
author | David Rodriguez <deivid.rodriguez@riseup.net> | 2024-05-10 16:14:26 +0200 |
---|---|---|
committer | git <svn-admin@ruby-lang.org> | 2024-05-13 09:08:16 +0000 |
commit | 69c87619bd7a69936c44cc0d323b11148400e894 (patch) | |
tree | 2bca61654d43f877789c76a95b5c3e8cb54866e1 | |
parent | e9262983430e7a758a4151e39151062ac00d67bf (diff) |
[rubygems/rubygems] Avoid standard requires while loading shared helpers
We should make sure Bundler does not trigger RubyGems require logic for
gem activation until it had the chance to register its own monkeypatches
to RubyGems.
https://github.com/rubygems/rubygems/commit/fbd2ff86b9
-rw-r--r-- | lib/bundler/constants.rb | 2 | ||||
-rw-r--r-- | lib/bundler/rubygems_integration.rb | 6 | ||||
-rw-r--r-- | lib/bundler/shared_helpers.rb | 10 |
3 files changed, 10 insertions, 8 deletions
diff --git a/lib/bundler/constants.rb b/lib/bundler/constants.rb index de9698b577..bcbd228b18 100644 --- a/lib/bundler/constants.rb +++ b/lib/bundler/constants.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "rbconfig" + module Bundler WINDOWS = RbConfig::CONFIG["host_os"] =~ /(msdos|mswin|djgpp|mingw)/ FREEBSD = RbConfig::CONFIG["host_os"].to_s.include?("bsd") diff --git a/lib/bundler/rubygems_integration.rb b/lib/bundler/rubygems_integration.rb index 494030eab2..6980b32236 100644 --- a/lib/bundler/rubygems_integration.rb +++ b/lib/bundler/rubygems_integration.rb @@ -4,9 +4,7 @@ require "rubygems" unless defined?(Gem) module Bundler class RubygemsIntegration - require "monitor" - - EXT_LOCK = Monitor.new + autoload :Monitor, "monitor" def initialize @replaced_methods = {} @@ -173,7 +171,7 @@ module Bundler end def ext_lock - EXT_LOCK + @ext_lock ||= Monitor.new end def spec_from_gem(path) diff --git a/lib/bundler/shared_helpers.rb b/lib/bundler/shared_helpers.rb index 78760e6fa4..28f0cdff19 100644 --- a/lib/bundler/shared_helpers.rb +++ b/lib/bundler/shared_helpers.rb @@ -1,15 +1,17 @@ # frozen_string_literal: true -require "pathname" -require "rbconfig" - require_relative "version" -require_relative "constants" require_relative "rubygems_integration" require_relative "current_ruby" module Bundler + autoload :WINDOWS, File.expand_path("constants", __dir__) + autoload :FREEBSD, File.expand_path("constants", __dir__) + autoload :NULL, File.expand_path("constants", __dir__) + module SharedHelpers + autoload :Pathname, "pathname" + def root gemfile = find_gemfile raise GemfileNotFound, "Could not locate Gemfile" unless gemfile |