Skip to content

Commit

Permalink
[rubygems/rubygems] Avoid standard requires while loading shared helpers
Browse files Browse the repository at this point in the history
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.

rubygems/rubygems@fbd2ff86b9
  • Loading branch information
deivid-rodriguez authored and matzbot committed May 13, 2024
1 parent e926298 commit 69c8761
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
2 changes: 2 additions & 0 deletions lib/bundler/constants.rb
Original file line number Diff line number Diff line change
@@ -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")
Expand Down
6 changes: 2 additions & 4 deletions lib/bundler/rubygems_integration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

module Bundler
class RubygemsIntegration
require "monitor"

EXT_LOCK = Monitor.new
autoload :Monitor, "monitor"

def initialize
@replaced_methods = {}
Expand Down Expand Up @@ -173,7 +171,7 @@ def ui=(obj)
end

def ext_lock
EXT_LOCK
@ext_lock ||= Monitor.new
end

def spec_from_gem(path)
Expand Down
10 changes: 6 additions & 4 deletions lib/bundler/shared_helpers.rb
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 69c8761

Please sign in to comment.