Merge pull request #16145 from Bo98/portable-ruby-3

Portable Ruby 3.1.4 (opt-in beta)
This commit is contained in:
Mike McQuaid 2023-10-27 16:31:52 +01:00 committed by GitHub
commit b5aec5492e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 74 additions and 25 deletions

View File

@ -4,7 +4,7 @@ source "https://rubygems.org"
# The default case (no envs), should always be a restrictive bound on the lowest supported minor version. # The default case (no envs), should always be a restrictive bound on the lowest supported minor version.
# This is the branch that Dependabot will use. # This is the branch that Dependabot will use.
if ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", "").empty? if ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", "").empty? && ENV.fetch("HOMEBREW_RUBY3", "").empty?
ruby "~> 2.6.0" ruby "~> 2.6.0"
else else
ruby ">= 2.6.0" ruby ">= 2.6.0"

View File

@ -465,7 +465,11 @@ module Homebrew
def cleanup_portable_ruby def cleanup_portable_ruby
vendor_dir = HOMEBREW_LIBRARY/"Homebrew/vendor" vendor_dir = HOMEBREW_LIBRARY/"Homebrew/vendor"
portable_ruby_latest_version = (vendor_dir/"portable-ruby-version").read.chomp portable_ruby_latest_version = if ENV["HOMEBREW_RUBY3"]
(vendor_dir/"portable-ruby-version").read.chomp
else
"2.6.10_1"
end
portable_rubies_to_remove = [] portable_rubies_to_remove = []
Pathname.glob(vendor_dir/"portable-ruby/*.*").select(&:directory?).each do |path| Pathname.glob(vendor_dir/"portable-ruby/*.*").select(&:directory?).each do |path|
@ -488,7 +492,9 @@ module Homebrew
end end
end end
def use_system_ruby?; end def use_system_ruby?
false
end
def cleanup_bootsnap def cleanup_bootsnap
bootsnap = cache/"bootsnap" bootsnap = cache/"bootsnap"

View File

@ -20,19 +20,37 @@ then
# use a x86_64 Portable Ruby. # use a x86_64 Portable Ruby.
[[ "${HOMEBREW_PHYSICAL_PROCESSOR}" == "arm64" && "${HOMEBREW_PREFIX}" == "/usr/local" ]] [[ "${HOMEBREW_PHYSICAL_PROCESSOR}" == "arm64" && "${HOMEBREW_PREFIX}" == "/usr/local" ]]
then then
ruby_FILENAME="portable-ruby-2.6.10_1.el_capitan.bottle.tar.gz" if [[ -n "${HOMEBREW_RUBY3}" ]]
ruby_SHA="61029cec31c68a1fae1fa90fa876adf43d0becff777da793f9b5c5577f00567a" then
ruby_FILENAME="portable-ruby-3.1.4.el_capitan.bottle.tar.gz"
ruby_SHA="02180ca8b8295422ae84921bcf034b7ee8ce5575488bd5e6a37a192e53cd5d34"
else
ruby_FILENAME="portable-ruby-2.6.10_1.el_capitan.bottle.tar.gz"
ruby_SHA="61029cec31c68a1fae1fa90fa876adf43d0becff777da793f9b5c5577f00567a"
fi
elif [[ "${HOMEBREW_PHYSICAL_PROCESSOR}" == "arm64" ]] elif [[ "${HOMEBREW_PHYSICAL_PROCESSOR}" == "arm64" ]]
then then
ruby_FILENAME="portable-ruby-2.6.10_1.arm64_big_sur.bottle.tar.gz" if [[ -n "${HOMEBREW_RUBY3}" ]]
ruby_SHA="905b0c3896164ae8067a22fff2fd0b80b16d3c8bb72441403eedf69da71ec717" then
ruby_FILENAME="portable-ruby-3.1.4.arm64_big_sur.bottle.tar.gz"
ruby_SHA="d783cbeb6e6ef0d71c0b442317b54554370decd6fac66bf2d4938c07a63f67be"
else
ruby_FILENAME="portable-ruby-2.6.10_1.arm64_big_sur.bottle.tar.gz"
ruby_SHA="905b0c3896164ae8067a22fff2fd0b80b16d3c8bb72441403eedf69da71ec717"
fi
fi fi
elif [[ -n "${HOMEBREW_LINUX}" ]] elif [[ -n "${HOMEBREW_LINUX}" ]]
then then
case "${HOMEBREW_PROCESSOR}" in case "${HOMEBREW_PROCESSOR}" in
x86_64) x86_64)
ruby_FILENAME="portable-ruby-2.6.10_1.x86_64_linux.bottle.tar.gz" if [[ -n "${HOMEBREW_RUBY3}" ]]
ruby_SHA="68923daf3e139482b977c3deba63a3b54ea37bb5f716482948878819ef911bad" then
ruby_FILENAME="portable-ruby-3.1.4.x86_64_linux.bottle.tar.gz"
ruby_SHA="f7be167f7ac4f296b9f4c5874ceeea4aafd9999c3c7f2b0378cae7dd273e2322"
else
ruby_FILENAME="portable-ruby-2.6.10_1.x86_64_linux.bottle.tar.gz"
ruby_SHA="68923daf3e139482b977c3deba63a3b54ea37bb5f716482948878819ef911bad"
fi
;; ;;
*) ;; *) ;;
esac esac
@ -53,8 +71,13 @@ then
fi fi
ruby_URLs+=( ruby_URLs+=(
"https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:${ruby_SHA}" "https://ghcr.io/v2/homebrew/portable-ruby/portable-ruby/blobs/sha256:${ruby_SHA}"
"https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.10_1/${ruby_FILENAME}"
) )
if [[ -n "${HOMEBREW_RUBY3}" ]]
then
ruby_URLs+=("https://github.com/Homebrew/homebrew-portable-ruby/releases/download/3.1.4/${ruby_FILENAME}")
else
ruby_URLs+=("https://github.com/Homebrew/homebrew-portable-ruby/releases/download/2.6.10_1/${ruby_FILENAME}")
fi
ruby_URL="${ruby_URLs[0]}" ruby_URL="${ruby_URLs[0]}"
fi fi
@ -300,7 +323,12 @@ homebrew-vendor-install() {
VENDOR_FILENAME="${!filename_var}" VENDOR_FILENAME="${!filename_var}"
VENDOR_SHA="${!sha_var}" VENDOR_SHA="${!sha_var}"
VENDOR_URL="${!url_var}" VENDOR_URL="${!url_var}"
VENDOR_VERSION="$(cat "${VENDOR_DIR}/portable-${VENDOR_NAME}-version")" if [[ -z "${HOMEBREW_RUBY3}" && "${VENDOR_NAME}" == "ruby" ]]
then
VENDOR_VERSION="2.6.10_1" # EOL - phasing out
else
VENDOR_VERSION="$(cat "${VENDOR_DIR}/portable-${VENDOR_NAME}-version")"
fi
if [[ -z "${VENDOR_URL}" || -z "${VENDOR_SHA}" ]] if [[ -z "${VENDOR_URL}" || -z "${VENDOR_SHA}" ]]
then then

View File

@ -208,6 +208,7 @@ module Homebrew
HOMEBREW_CACHE HOMEBREW_CACHE
HOMEBREW_LOGS HOMEBREW_LOGS
HOMEBREW_TEMP HOMEBREW_TEMP
HOMEBREW_RUBY3
] ]
allowed_test_env << "HOMEBREW_USE_RUBY_FROM_PATH" if Homebrew::EnvConfig.developer? allowed_test_env << "HOMEBREW_USE_RUBY_FROM_PATH" if Homebrew::EnvConfig.developer?
Homebrew::EnvConfig::ENVS.keys.map(&:to_s).each do |env| Homebrew::EnvConfig::ENVS.keys.map(&:to_s).each do |env|

View File

@ -6,7 +6,7 @@ module Homebrew
undef use_system_ruby? undef use_system_ruby?
def use_system_ruby? def use_system_ruby?
return false if Homebrew::EnvConfig.force_vendor_ruby? return false if Homebrew::EnvConfig.force_vendor_ruby? || ENV["HOMEBREW_RUBY3"]
rubies = [which("ruby"), which("ruby", ORIGINAL_PATHS)].compact rubies = [which("ruby"), which("ruby", ORIGINAL_PATHS)].compact
system_ruby = Pathname.new("/usr/bin/ruby") system_ruby = Pathname.new("/usr/bin/ruby")

View File

@ -6,7 +6,7 @@ module Homebrew
undef use_system_ruby? undef use_system_ruby?
def use_system_ruby? def use_system_ruby?
return false if Homebrew::EnvConfig.force_vendor_ruby? return false if Homebrew::EnvConfig.force_vendor_ruby? || ENV["HOMEBREW_RUBY3"]
ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"].present? ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"].present?
end end

View File

@ -3,7 +3,9 @@
# Disable Rails cops, as we haven't required active_support yet. # Disable Rails cops, as we haven't required active_support yet.
# rubocop:disable Rails # rubocop:disable Rails
homebrew_bootsnap_enabled = ENV["HOMEBREW_NO_BOOTSNAP"].nil? && !ENV["HOMEBREW_BOOTSNAP"].nil? homebrew_bootsnap_enabled = ENV["HOMEBREW_NO_BOOTSNAP"].nil? &&
!ENV["HOMEBREW_BOOTSNAP"].nil? &&
ENV["HOMEBREW_RUBY3"].nil?
# we need some development tools to build bootsnap native code # we need some development tools to build bootsnap native code
homebrew_bootsnap_enabled &&= if ENV["HOMEBREW_MACOS_VERSION"] homebrew_bootsnap_enabled &&= if ENV["HOMEBREW_MACOS_VERSION"]

View File

@ -9,6 +9,7 @@ describe "RuboCop" do
allowlist = %w[ allowlist = %w[
HOMEBREW_TESTS HOMEBREW_TESTS
HOMEBREW_USE_RUBY_FROM_PATH HOMEBREW_USE_RUBY_FROM_PATH
HOMEBREW_RUBY3
] ]
ENV.delete(key) if key.start_with?("HOMEBREW_") && allowlist.exclude?(key) ENV.delete(key) if key.start_with?("HOMEBREW_") && allowlist.exclude?(key)
end end

View File

@ -78,13 +78,15 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
].compact.join(File::PATH_SEPARATOR) ].compact.join(File::PATH_SEPARATOR)
env.merge!( env.merge!(
"PATH" => path, "PATH" => path,
"HOMEBREW_PATH" => path, "HOMEBREW_PATH" => path,
"HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew", "HOMEBREW_BREW_FILE" => HOMEBREW_PREFIX/"bin/brew",
"HOMEBREW_INTEGRATION_TEST" => command_id_from_args(args), "HOMEBREW_INTEGRATION_TEST" => command_id_from_args(args),
"HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR, "HOMEBREW_TEST_TMPDIR" => TEST_TMPDIR,
"HOMEBREW_DEV_CMD_RUN" => "true", "HOMEBREW_DEV_CMD_RUN" => "true",
"GEM_HOME" => nil, "HOMEBREW_USE_RUBY_FROM_PATH" => ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", nil),
"HOMEBREW_RUBY3" => ENV.fetch("HOMEBREW_RUBY3", nil),
"GEM_HOME" => nil,
) )
@ruby_args ||= begin @ruby_args ||= begin
@ -129,8 +131,12 @@ RSpec.shared_context "integration test" do # rubocop:disable RSpec/ContextWordin
end end
def brew_sh(*args) def brew_sh(*args)
env = {
"HOMEBREW_USE_RUBY_FROM_PATH" => ENV.fetch("HOMEBREW_USE_RUBY_FROM_PATH", nil),
"HOMEBREW_RUBY3" => ENV.fetch("HOMEBREW_RUBY3", nil),
}
Bundler.with_unbundled_env do Bundler.with_unbundled_env do
stdout, stderr, status = Open3.capture3("#{ENV.fetch("HOMEBREW_PREFIX")}/bin/brew", *args) stdout, stderr, status = Open3.capture3(env, "#{ENV.fetch("HOMEBREW_PREFIX")}/bin/brew", *args)
$stdout.print stdout $stdout.print stdout
$stderr.print stderr $stderr.print stderr
status status

View File

@ -70,7 +70,7 @@ find_ruby() {
# HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH are set by brew.sh # HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH are set by brew.sh
# shellcheck disable=SC2154 # shellcheck disable=SC2154
need_vendored_ruby() { need_vendored_ruby() {
if [[ -n "${HOMEBREW_FORCE_VENDOR_RUBY}" ]] if [[ -n "${HOMEBREW_FORCE_VENDOR_RUBY}" || -n "${HOMEBREW_RUBY3}" ]]
then then
return 0 return 0
elif [[ -n "${HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH}" ]] && ! can_use_ruby_from_path elif [[ -n "${HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH}" ]] && ! can_use_ruby_from_path
@ -118,7 +118,12 @@ If there's no Homebrew Portable Ruby available for your processor:
vendor_ruby_root="${vendor_dir}/portable-ruby/current" vendor_ruby_root="${vendor_dir}/portable-ruby/current"
vendor_ruby_path="${vendor_ruby_root}/bin/ruby" vendor_ruby_path="${vendor_ruby_root}/bin/ruby"
vendor_ruby_terminfo="${vendor_ruby_root}/share/terminfo" vendor_ruby_terminfo="${vendor_ruby_root}/share/terminfo"
vendor_ruby_latest_version="$(cat "${vendor_dir}/portable-ruby-version")" if [[ -n "${HOMEBREW_RUBY3}" ]]
then
vendor_ruby_latest_version="$(cat "${vendor_dir}/portable-ruby-version")"
else
vendor_ruby_latest_version="2.6.10_1" # EOL - phasing out
fi
vendor_ruby_current_version="$(readlink "${vendor_ruby_root}")" vendor_ruby_current_version="$(readlink "${vendor_ruby_root}")"
unset HOMEBREW_RUBY_PATH unset HOMEBREW_RUBY_PATH

View File

@ -1 +1 @@
2.6.10_1 3.1.4