diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index 617d074a00..f4110dc106 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -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. diff --git a/Library/Homebrew/standalone/init.rb b/Library/Homebrew/standalone/init.rb index 2e72ae1db9..fafbaa2ab5 100644 --- a/Library/Homebrew/standalone/init.rb +++ b/Library/Homebrew/standalone/init.rb @@ -39,7 +39,13 @@ if !gems_vendored && !ENV["HOMEBREW_SKIP_INITIAL_GEM_INSTALL"] ENV["HOMEBREW_SKIP_INITIAL_GEM_INSTALL"] = "1" end -$LOAD_PATH.push 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" diff --git a/Library/Homebrew/test/spec_helper.rb b/Library/Homebrew/test/spec_helper.rb index 3b17651570..36df0e8971 100644 --- a/Library/Homebrew/test/spec_helper.rb +++ b/Library/Homebrew/test/spec_helper.rb @@ -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"