diff --git a/Library/Homebrew/brew.sh b/Library/Homebrew/brew.sh index 427602055c..ba6592eba5 100644 --- a/Library/Homebrew/brew.sh +++ b/Library/Homebrew/brew.sh @@ -127,6 +127,17 @@ then HOMEBREW_CACHE="${HOMEBREW_CACHE:-${HOME}/Library/Caches/Homebrew}" HOMEBREW_LOGS="${HOMEBREW_LOGS:-${HOME}/Library/Logs/Homebrew}" HOMEBREW_SYSTEM_TEMP="/private/tmp" + + # Set a variable when the macOS system Ruby is new enough to avoid spawning + # a Ruby process unnecessarily. + if [[ "$HOMEBREW_MACOS_VERSION_NUMERIC" -lt "101303" ]] + then + unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH + else + # Used in ruby.sh. + # shellcheck disable=SC2034 + HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH="1" + fi else HOMEBREW_PROCESSOR="$(uname -m)" HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew" @@ -157,6 +168,8 @@ else HOMEBREW_CACHE="${HOMEBREW_CACHE:-${CACHE_HOME}/Homebrew}" HOMEBREW_LOGS="${HOMEBREW_LOGS:-${CACHE_HOME}/Homebrew/Logs}" HOMEBREW_SYSTEM_TEMP="/tmp" + + unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH fi if [[ -n "$HOMEBREW_MACOS" || -n "$HOMEBREW_FORCE_HOMEBREW_ON_LINUX" ]] diff --git a/Library/Homebrew/utils/ruby.sh b/Library/Homebrew/utils/ruby.sh index 6aff2185a8..b1a2988505 100644 --- a/Library/Homebrew/utils/ruby.sh +++ b/Library/Homebrew/utils/ruby.sh @@ -35,7 +35,10 @@ setup-ruby-path() { HOMEBREW_RUBY_PATH="$(type -P ruby)" fi - if [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]] + if [[ -n "$HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH" ]] + then + ruby_version_new_enough="true" + elif [[ -n "$HOMEBREW_RUBY_PATH" && -z "$HOMEBREW_FORCE_VENDOR_RUBY" ]] then ruby_version_new_enough="$("$HOMEBREW_RUBY_PATH" --disable=gems -rrubygems -e "puts Gem::Version.new(RUBY_VERSION.to_s.dup) >= Gem::Version.new('$minimum_ruby_version')")" fi