Tweak library load path insertion to be as early as possible

This commit is contained in:
Bo Anderson 2024-01-18 14:54:14 +00:00
parent 3d443e2ed3
commit ec0434c549
No known key found for this signature in database
3 changed files with 11 additions and 3 deletions

View File

@ -202,8 +202,10 @@ Performance/MethodObjectAsBlock:
Rails:
# Selectively enable what we want.
Enabled: false
# Do not use ActiveSupport in RuboCops.
Exclude:
# This file is loaded before any extra methods are defined.
- "Homebrew/standalone/init.rb"
# Do not use ActiveSupport in RuboCops.
- "Homebrew/rubocops/**/*"
# These relate to ActiveSupport and not other parts of Rails.

View File

@ -39,7 +39,13 @@ if !gems_vendored && !ENV["HOMEBREW_SKIP_INITIAL_GEM_INSTALL"]
ENV["HOMEBREW_SKIP_INITIAL_GEM_INSTALL"] = "1"
end
$LOAD_PATH.unshift HOMEBREW_LIBRARY_PATH.to_s unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s)
unless $LOAD_PATH.include?(HOMEBREW_LIBRARY_PATH.to_s)
# Insert the path after any existing Homebrew paths (e.g. those inserted by tests and parent processes)
last_homebrew_path_idx = $LOAD_PATH.rindex do |path|
path.start_with?(HOMEBREW_LIBRARY_PATH.to_s) && !path.include?("vendor/portable-ruby")
end || -1
$LOAD_PATH.insert(last_homebrew_path_idx + 1, HOMEBREW_LIBRARY_PATH.to_s)
end
require_relative "../vendor/bundle/bundler/setup"
$LOAD_PATH.unshift "#{HOMEBREW_LIBRARY_PATH}/vendor/bundle/#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/" \
"bundler-#{Homebrew::HOMEBREW_BUNDLER_VERSION}/lib"

View File

@ -33,7 +33,7 @@ require "find"
require "byebug"
require "timeout"
$LOAD_PATH.push(File.expand_path("#{ENV.fetch("HOMEBREW_LIBRARY")}/Homebrew/test/support/lib"))
$LOAD_PATH.unshift(File.expand_path("#{ENV.fetch("HOMEBREW_LIBRARY")}/Homebrew/test/support/lib"))
require_relative "../global"