diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 7b19f519b7..7fad5c9968 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -586,7 +586,7 @@ then # Set a variable when the macOS system Ruby is new enough to avoid spawning # a Ruby process unnecessarily. - if [[ "${HOMEBREW_MACOS_VERSION_NUMERIC}" -lt "120601" ]] + if [[ "${HOMEBREW_MACOS_VERSION_NUMERIC}" -lt "120601" || -n "${HOMEBREW_RUBY3}" ]] then unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH else diff --git a/Library/Homebrew/extend/os/linux/cleanup.rb b/Library/Homebrew/extend/os/linux/cleanup.rb index 17eb8c162c..85a53d78b7 100644 --- a/Library/Homebrew/extend/os/linux/cleanup.rb +++ b/Library/Homebrew/extend/os/linux/cleanup.rb @@ -6,7 +6,7 @@ module Homebrew undef use_system_ruby? def use_system_ruby? - return false if Homebrew::EnvConfig.force_vendor_ruby? || ENV["HOMEBREW_RUBY3"] + return false if Homebrew::EnvConfig.force_vendor_ruby? rubies = [which("ruby"), which("ruby", ORIGINAL_PATHS)].compact system_ruby = Pathname.new("/usr/bin/ruby") @@ -15,7 +15,7 @@ module Homebrew check_ruby_version = HOMEBREW_LIBRARY_PATH/"utils/ruby_check_version_script.rb" rubies.uniq.any? do |ruby| quiet_system ruby, "--enable-frozen-string-literal", "--disable=gems,did_you_mean,rubyopt", - check_ruby_version, HOMEBREW_REQUIRED_RUBY_VERSION + check_ruby_version, RUBY_VERSION end end end diff --git a/Library/Homebrew/extend/os/mac/cleanup.rb b/Library/Homebrew/extend/os/mac/cleanup.rb index ea63f03095..8fa20b62af 100644 --- a/Library/Homebrew/extend/os/mac/cleanup.rb +++ b/Library/Homebrew/extend/os/mac/cleanup.rb @@ -6,7 +6,7 @@ module Homebrew undef use_system_ruby? def use_system_ruby? - return false if Homebrew::EnvConfig.force_vendor_ruby? || ENV["HOMEBREW_RUBY3"] + return false if Homebrew::EnvConfig.force_vendor_ruby? ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"].present? end diff --git a/Library/Homebrew/extend/os/mac/diagnostic.rb b/Library/Homebrew/extend/os/mac/diagnostic.rb index 35b969cada..a9d7321c80 100644 --- a/Library/Homebrew/extend/os/mac/diagnostic.rb +++ b/Library/Homebrew/extend/os/mac/diagnostic.rb @@ -205,6 +205,7 @@ module Homebrew 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? diff --git a/Library/Homebrew/utils/ruby.sh b/Library/Homebrew/utils/ruby.sh index ec76d66933..322113501b 100644 --- a/Library/Homebrew/utils/ruby.sh +++ b/Library/Homebrew/utils/ruby.sh @@ -10,9 +10,16 @@ test_ruby() { return 1 fi + if [[ -n "${HOMEBREW_RUBY3}" ]] + then + required_ruby_version="3.1.0" + else + required_ruby_version="${HOMEBREW_REQUIRED_RUBY_VERSION}" + fi + "$1" --enable-frozen-string-literal --disable=gems,did_you_mean,rubyopt \ "${HOMEBREW_LIBRARY}/Homebrew/utils/ruby_check_version_script.rb" \ - "${HOMEBREW_REQUIRED_RUBY_VERSION}" 2>/dev/null + "${required_ruby_version}" 2>/dev/null } can_use_ruby_from_path() { @@ -70,7 +77,7 @@ find_ruby() { # HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH are set by brew.sh # shellcheck disable=SC2154 need_vendored_ruby() { - if [[ -n "${HOMEBREW_FORCE_VENDOR_RUBY}" || -n "${HOMEBREW_RUBY3}" ]] + if [[ -n "${HOMEBREW_FORCE_VENDOR_RUBY}" ]] then return 0 elif [[ -n "${HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH}" ]] && ! can_use_ruby_from_path