Remove sitedir from LOAD_PATH

This commit is contained in:
Bo Anderson 2022-10-24 19:42:49 +01:00
parent 6a7eac25e1
commit 8cb056c657
No known key found for this signature in database
GPG Key ID: 3DB94E204E137D65
3 changed files with 9 additions and 2 deletions

View File

@ -724,7 +724,7 @@ then
fi
# Disable Ruby options we don't need.
RUBY_DISABLE_OPTIONS="--disable=rubyopt"
RUBY_DISABLE_OPTIONS="--disable=gems,rubyopt"
if [[ -z "${HOMEBREW_RUBY_WARNINGS}" ]]
then

View File

@ -1,8 +1,12 @@
# typed: true
# frozen_string_literal: true
require "pathname"
# We trust base Ruby to provide what we need.
# Don't look into the user-installed sitedir, which may contain older versions of RubyGems.
require "rbconfig"
$LOAD_PATH.reject! { |path| path.start_with?(RbConfig::CONFIG["sitedir"]) }
require "pathname"
HOMEBREW_LIBRARY_PATH = Pathname(__dir__).parent.realpath.freeze
require_relative "../utils/gems"

View File

@ -44,6 +44,9 @@ module Homebrew
end
def setup_gem_environment!(setup_path: true)
require "rubygems"
raise "RubyGems too old!" if Gem::Version.new(Gem::VERSION) < Gem::Version.new("2.2.0")
# Match where our bundler gems are.
gem_home = "#{HOMEBREW_LIBRARY_PATH}/vendor/bundle/ruby/#{RbConfig::CONFIG["ruby_version"]}"
Gem.paths = {