Merge pull request #16192 from Bo98/system-ruby-3
Support system Ruby 3 on Linux
This commit is contained in:
commit
3baec056e7
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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?
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user