Don't check system Ruby is new enough when unnecessary.

We know this is the case in macOS >=10.13.3 so save a Ruby process call.
This commit is contained in:
Mike McQuaid 2019-04-18 17:54:05 +09:00
parent ef2e297d3b
commit 9e7b98d3e2
No known key found for this signature in database
GPG Key ID: 48A898132FD8EE70
2 changed files with 17 additions and 1 deletions

View File

@ -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" ]]

View File

@ -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