commit
						6938fb7781
					
				@ -81,8 +81,3 @@ gem "plist"
 | 
			
		||||
gem "ruby-macho"
 | 
			
		||||
gem "sorbet-runtime"
 | 
			
		||||
gem "warning"
 | 
			
		||||
 | 
			
		||||
# TODO: remove when HOMEBREW_REQUIRED_RUBY_VERSION >= 2.7
 | 
			
		||||
install_if -> { RUBY_VERSION < "2.7" } do
 | 
			
		||||
  gem "did_you_mean"
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -18,7 +18,6 @@ GEM
 | 
			
		||||
    commander (4.6.0)
 | 
			
		||||
      highline (~> 2.0.0)
 | 
			
		||||
    concurrent-ruby (1.2.2)
 | 
			
		||||
    did_you_mean (1.6.3)
 | 
			
		||||
    diff-lcs (1.5.0)
 | 
			
		||||
    docile (1.4.0)
 | 
			
		||||
    elftools (1.2.0)
 | 
			
		||||
@ -193,7 +192,6 @@ DEPENDENCIES
 | 
			
		||||
  addressable
 | 
			
		||||
  bootsnap
 | 
			
		||||
  byebug
 | 
			
		||||
  did_you_mean
 | 
			
		||||
  json_schemer
 | 
			
		||||
  minitest
 | 
			
		||||
  parallel_tests
 | 
			
		||||
 | 
			
		||||
@ -585,9 +585,6 @@ then
 | 
			
		||||
      HOMEBREW_FORCE_BREWED_GIT="1"
 | 
			
		||||
    fi
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  # System Ruby usage is deprecated. TODO: clean this up once 2.6 is fully ditched.
 | 
			
		||||
  unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
 | 
			
		||||
else
 | 
			
		||||
  HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew"
 | 
			
		||||
  # Don't try to follow /etc/os-release
 | 
			
		||||
@ -651,7 +648,6 @@ Your Git executable: $(unset git && type -p "${HOMEBREW_GIT}")"
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION="2.13"
 | 
			
		||||
  unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
 | 
			
		||||
 | 
			
		||||
  HOMEBREW_CORE_REPOSITORY_ORIGIN="$("${HOMEBREW_GIT}" -C "${HOMEBREW_CORE_REPOSITORY}" remote get-url origin 2>/dev/null)"
 | 
			
		||||
  if [[ "${HOMEBREW_CORE_REPOSITORY_ORIGIN}" =~ (/linuxbrew|Linuxbrew/homebrew)-core(\.git)?$ ]]
 | 
			
		||||
@ -742,7 +738,6 @@ export HOMEBREW_USER_AGENT
 | 
			
		||||
export HOMEBREW_USER_AGENT_CURL
 | 
			
		||||
export HOMEBREW_API_DEFAULT_DOMAIN
 | 
			
		||||
export HOMEBREW_BOTTLE_DEFAULT_DOMAIN
 | 
			
		||||
export HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
 | 
			
		||||
export HOMEBREW_CURL_SPEED_LIMIT
 | 
			
		||||
export HOMEBREW_CURL_SPEED_TIME
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -33,9 +33,6 @@ module Homebrew
 | 
			
		||||
 | 
			
		||||
    ENV["BUNDLE_WITH"] = Homebrew.valid_gem_groups.join(":")
 | 
			
		||||
 | 
			
		||||
    # System Ruby does not pick up the correct SDK by default.
 | 
			
		||||
    ENV["SDKROOT"] = MacOS.sdk_path if ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"]
 | 
			
		||||
 | 
			
		||||
    ohai "cd #{HOMEBREW_LIBRARY_PATH}"
 | 
			
		||||
    HOMEBREW_LIBRARY_PATH.cd do
 | 
			
		||||
      if args.update
 | 
			
		||||
 | 
			
		||||
@ -8,7 +8,7 @@ module Homebrew
 | 
			
		||||
    def use_system_ruby?
 | 
			
		||||
      return false if Homebrew::EnvConfig.force_vendor_ruby?
 | 
			
		||||
 | 
			
		||||
      ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"].present?
 | 
			
		||||
      Homebrew::EnvConfig.developer? && ENV["HOMEBREW_USE_RUBY_FROM_PATH"].present?
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -204,19 +204,6 @@ module Homebrew
 | 
			
		||||
        EOS
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def check_ruby_version
 | 
			
		||||
        return unless ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"]
 | 
			
		||||
        return if RUBY_VERSION == HOMEBREW_REQUIRED_RUBY_VERSION
 | 
			
		||||
        return if Homebrew::EnvConfig.developer? && OS::Mac.version.prerelease?
 | 
			
		||||
 | 
			
		||||
        <<~EOS
 | 
			
		||||
          Ruby version #{RUBY_VERSION} is unsupported on macOS #{MacOS.version}. Homebrew
 | 
			
		||||
          is developed and tested on Ruby #{HOMEBREW_REQUIRED_RUBY_VERSION}, and may not work correctly
 | 
			
		||||
          on other Rubies. Patches are accepted as long as they don't cause breakage
 | 
			
		||||
          on supported Rubies.
 | 
			
		||||
        EOS
 | 
			
		||||
      end
 | 
			
		||||
 | 
			
		||||
      def check_xcode_prefix
 | 
			
		||||
        prefix = MacOS::Xcode.prefix
 | 
			
		||||
        return if prefix.nil?
 | 
			
		||||
 | 
			
		||||
@ -7,18 +7,9 @@ module SystemConfig
 | 
			
		||||
  class << self
 | 
			
		||||
    include SystemCommand::Mixin
 | 
			
		||||
 | 
			
		||||
    undef describe_homebrew_ruby, describe_clang
 | 
			
		||||
 | 
			
		||||
    def describe_homebrew_ruby
 | 
			
		||||
      s = describe_homebrew_ruby_version
 | 
			
		||||
 | 
			
		||||
      if RUBY_PATH.to_s.match?(%r{^/System/Library/Frameworks/Ruby\.framework/Versions/[12]\.[089]/usr/bin/ruby})
 | 
			
		||||
        s
 | 
			
		||||
      else
 | 
			
		||||
        "#{s} => #{RUBY_PATH}"
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
    undef describe_clang
 | 
			
		||||
 | 
			
		||||
    sig { returns(String) }
 | 
			
		||||
    def describe_clang
 | 
			
		||||
      return "N/A" if clang.null?
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -40,9 +40,4 @@ $LOAD_PATH.push HOMEBREW_LIBRARY_PATH.to_s unless $LOAD_PATH.include?(HOMEBREW_L
 | 
			
		||||
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"
 | 
			
		||||
if ruby_major == 2 && ruby_minor == 6
 | 
			
		||||
  # TEMP: Ruby 3 transition
 | 
			
		||||
  $LOAD_PATH.unshift "#{HOMEBREW_LIBRARY_PATH}/vendor/bundle/#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/" \
 | 
			
		||||
                     "did_you_mean-1.6.3/lib"
 | 
			
		||||
end
 | 
			
		||||
$LOAD_PATH.uniq!
 | 
			
		||||
 | 
			
		||||
@ -92,19 +92,9 @@ module SystemConfig
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    sig { returns(String) }
 | 
			
		||||
    def describe_homebrew_ruby_version
 | 
			
		||||
      case RUBY_VERSION
 | 
			
		||||
      when /^1\.[89]/, /^2\.0/
 | 
			
		||||
        "#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
 | 
			
		||||
      else
 | 
			
		||||
        RUBY_VERSION
 | 
			
		||||
      end
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    sig { returns(String) }
 | 
			
		||||
    def describe_homebrew_ruby
 | 
			
		||||
      "#{describe_homebrew_ruby_version} => #{RUBY_PATH}"
 | 
			
		||||
      "#{RUBY_VERSION} => #{RUBY_PATH}"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    sig { returns(T.nilable(String)) }
 | 
			
		||||
 | 
			
		||||
@ -30,7 +30,7 @@ describe "brew irb" do
 | 
			
		||||
      # TODO: newer Ruby only supports history saving in interactive sessions
 | 
			
		||||
      # and not if you feed in data from a file or stdin like we are doing here.
 | 
			
		||||
      # The test will need to be adjusted for this to work.
 | 
			
		||||
      expect(history_file).to exist if RUBY_VERSION < "2.7"
 | 
			
		||||
      # expect(history_file).to exist
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -30,17 +30,6 @@ describe Homebrew::Diagnostic::Checks do
 | 
			
		||||
      .to match("Xcode alone is not sufficient on El Capitan")
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  specify "#check_ruby_version" do
 | 
			
		||||
    macos_version = MacOSVersion.new("10.12")
 | 
			
		||||
    allow(OS::Mac).to receive(:version).and_return(macos_version)
 | 
			
		||||
    allow(OS::Mac).to receive(:full_version).and_return(macos_version)
 | 
			
		||||
    stub_const("RUBY_VERSION", "1.8.6")
 | 
			
		||||
    ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"] = "1"
 | 
			
		||||
 | 
			
		||||
    expect(checks.check_ruby_version)
 | 
			
		||||
      .to match "Ruby version 1.8.6 is unsupported on macOS 10.12"
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  describe "#check_if_supported_sdk_available" do
 | 
			
		||||
    let(:macos_version) { MacOSVersion.new("11") }
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -177,14 +177,6 @@ module Homebrew
 | 
			
		||||
  def user_gem_groups
 | 
			
		||||
    @user_gem_groups ||= if GEM_GROUPS_FILE.exist?
 | 
			
		||||
      GEM_GROUPS_FILE.readlines(chomp: true)
 | 
			
		||||
    elsif RUBY_VERSION < "2.7"
 | 
			
		||||
      # Backwards compatibility. This elsif block removed by the end of 2023.
 | 
			
		||||
      # We will not support this in Ruby >=2.7.
 | 
			
		||||
      require "settings"
 | 
			
		||||
      groups = Homebrew::Settings.read(:gemgroups)&.split(";") || []
 | 
			
		||||
      write_user_gem_groups(groups)
 | 
			
		||||
      Homebrew::Settings.delete(:gemgroups)
 | 
			
		||||
      groups
 | 
			
		||||
    else
 | 
			
		||||
      []
 | 
			
		||||
    end
 | 
			
		||||
@ -213,14 +205,7 @@ module Homebrew
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def forget_user_gem_groups!
 | 
			
		||||
    if GEM_GROUPS_FILE.exist?
 | 
			
		||||
      GEM_GROUPS_FILE.truncate(0)
 | 
			
		||||
    elsif RUBY_VERSION < "2.7"
 | 
			
		||||
      # Backwards compatibility. This else block can be removed by the end of 2023.
 | 
			
		||||
      # We will not support this in Ruby >=2.7.
 | 
			
		||||
      require "settings"
 | 
			
		||||
      Homebrew::Settings.delete(:gemgroups)
 | 
			
		||||
    end
 | 
			
		||||
    GEM_GROUPS_FILE.truncate(0) if GEM_GROUPS_FILE.exist?
 | 
			
		||||
    @user_gem_groups = []
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
@ -239,7 +224,6 @@ module Homebrew
 | 
			
		||||
    old_bundle_gemfile = ENV.fetch("BUNDLE_GEMFILE", nil)
 | 
			
		||||
    old_bundle_with = ENV.fetch("BUNDLE_WITH", nil)
 | 
			
		||||
    old_bundle_frozen = ENV.fetch("BUNDLE_FROZEN", nil)
 | 
			
		||||
    old_sdkroot = ENV.fetch("SDKROOT", nil)
 | 
			
		||||
 | 
			
		||||
    invalid_groups = groups - valid_gem_groups
 | 
			
		||||
    raise ArgumentError, "Invalid gem groups: #{invalid_groups.join(", ")}" unless invalid_groups.empty?
 | 
			
		||||
@ -267,13 +251,6 @@ module Homebrew
 | 
			
		||||
    ENV["BUNDLE_WITH"] = groups.join(" ")
 | 
			
		||||
    ENV["BUNDLE_FROZEN"] = "true"
 | 
			
		||||
 | 
			
		||||
    # System Ruby does not pick up the correct SDK by default.
 | 
			
		||||
    if ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"]
 | 
			
		||||
      macos_major = ENV.fetch("HOMEBREW_MACOS_VERSION").partition(".").first
 | 
			
		||||
      sdkroot = "/Library/Developer/CommandLineTools/SDKs/MacOSX#{macos_major}.sdk"
 | 
			
		||||
      ENV["SDKROOT"] = sdkroot if Dir.exist?(sdkroot)
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    if @bundle_installed_groups != groups
 | 
			
		||||
      bundle = File.join(find_in_path("bundle"), "bundle")
 | 
			
		||||
      bundle_check_output = `#{bundle} check 2>&1`
 | 
			
		||||
@ -367,6 +344,5 @@ module Homebrew
 | 
			
		||||
      ENV["BUNDLE_WITH"] = old_bundle_with
 | 
			
		||||
      ENV["BUNDLE_FROZEN"] = old_bundle_frozen
 | 
			
		||||
    end
 | 
			
		||||
    ENV["SDKROOT"] = old_sdkroot
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
 | 
			
		||||
@ -18,6 +18,10 @@ test_ruby() {
 | 
			
		||||
    "${HOMEBREW_REQUIRED_RUBY_VERSION}" 2>/dev/null
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
system_ruby_supported() {
 | 
			
		||||
  ([[ -z "${HOMEBREW_MACOS}" ]] || can_use_ruby_from_path)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
can_use_ruby_from_path() {
 | 
			
		||||
  if [[ -n "${HOMEBREW_DEVELOPER}" || -n "${HOMEBREW_TESTS}" ]] && [[ -n "${HOMEBREW_USE_RUBY_FROM_PATH}" ]]
 | 
			
		||||
  then
 | 
			
		||||
@ -39,47 +43,37 @@ find_first_valid_ruby() {
 | 
			
		||||
  done
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# HOMEBREW_MACOS is set by brew.sh
 | 
			
		||||
# HOMEBREW_PATH is set by global.rb
 | 
			
		||||
# shellcheck disable=SC2154
 | 
			
		||||
find_ruby() {
 | 
			
		||||
  if [[ -n "${HOMEBREW_MACOS}" ]] && ! can_use_ruby_from_path
 | 
			
		||||
  local valid_ruby
 | 
			
		||||
 | 
			
		||||
  # Prioritise rubies from the filtered path (/usr/bin etc) unless explicitly overridden.
 | 
			
		||||
  if ! can_use_ruby_from_path
 | 
			
		||||
  then
 | 
			
		||||
    echo "/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby"
 | 
			
		||||
  else
 | 
			
		||||
    local valid_ruby
 | 
			
		||||
 | 
			
		||||
    # Prioritise rubies from the filtered path (/usr/bin etc) unless explicitly overridden.
 | 
			
		||||
    if ! can_use_ruby_from_path
 | 
			
		||||
    then
 | 
			
		||||
      # function which() is set by brew.sh
 | 
			
		||||
      # it is aliased to `type -P`
 | 
			
		||||
      # shellcheck disable=SC2230
 | 
			
		||||
      valid_ruby=$(find_first_valid_ruby < <(which -a ruby))
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    if [[ -z "${valid_ruby}" ]]
 | 
			
		||||
    then
 | 
			
		||||
      # Same as above
 | 
			
		||||
      # shellcheck disable=SC2230
 | 
			
		||||
      valid_ruby=$(find_first_valid_ruby < <(PATH="${HOMEBREW_PATH}" which -a ruby))
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    echo "${valid_ruby}"
 | 
			
		||||
    # function which() is set by brew.sh
 | 
			
		||||
    # it is aliased to `type -P`
 | 
			
		||||
    # shellcheck disable=SC2230
 | 
			
		||||
    valid_ruby=$(find_first_valid_ruby < <(which -a ruby))
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  if [[ -z "${valid_ruby}" ]]
 | 
			
		||||
  then
 | 
			
		||||
    # Same as above
 | 
			
		||||
    # shellcheck disable=SC2230
 | 
			
		||||
    valid_ruby=$(find_first_valid_ruby < <(PATH="${HOMEBREW_PATH}" which -a ruby))
 | 
			
		||||
  fi
 | 
			
		||||
 | 
			
		||||
  echo "${valid_ruby}"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# HOMEBREW_FORCE_VENDOR_RUBY is from the user environment
 | 
			
		||||
# HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH are set by brew.sh
 | 
			
		||||
# shellcheck disable=SC2154
 | 
			
		||||
need_vendored_ruby() {
 | 
			
		||||
  if [[ -n "${HOMEBREW_FORCE_VENDOR_RUBY}" ]]
 | 
			
		||||
  then
 | 
			
		||||
    return 0
 | 
			
		||||
  elif [[ -n "${HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH}" ]] && ! can_use_ruby_from_path
 | 
			
		||||
  then
 | 
			
		||||
    return 1
 | 
			
		||||
  elif ([[ -z "${HOMEBREW_MACOS}" ]] || can_use_ruby_from_path) && test_ruby "${HOMEBREW_RUBY_PATH}"
 | 
			
		||||
  elif system_ruby_supported && test_ruby "${HOMEBREW_RUBY_PATH}"
 | 
			
		||||
  then
 | 
			
		||||
    return 1
 | 
			
		||||
  else
 | 
			
		||||
@ -96,8 +90,6 @@ setup-ruby-path() {
 | 
			
		||||
  local vendor_ruby_terminfo
 | 
			
		||||
  local vendor_ruby_latest_version
 | 
			
		||||
  local vendor_ruby_current_version
 | 
			
		||||
  # When bumping check if HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH (in brew.sh)
 | 
			
		||||
  # also needs to be changed.
 | 
			
		||||
  local ruby_exec
 | 
			
		||||
  local upgrade_fail
 | 
			
		||||
  local install_fail
 | 
			
		||||
@ -140,7 +132,11 @@ If there's no Homebrew Portable Ruby available for your processor:
 | 
			
		||||
      brew vendor-install ruby || odie "${upgrade_fail}"
 | 
			
		||||
    fi
 | 
			
		||||
  else
 | 
			
		||||
    HOMEBREW_RUBY_PATH="$(find_ruby)"
 | 
			
		||||
    if system_ruby_supported
 | 
			
		||||
    then
 | 
			
		||||
      HOMEBREW_RUBY_PATH="$(find_ruby)"
 | 
			
		||||
    fi
 | 
			
		||||
 | 
			
		||||
    if need_vendored_ruby
 | 
			
		||||
    then
 | 
			
		||||
      brew vendor-install ruby || odie "${install_fail}"
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user