Skip to content

Commit 688d87e

Browse files
committed
Remove Ruby 2.6 & macOS system Ruby support code
1 parent 4c20298 commit 688d87e

File tree

13 files changed

+32
-123
lines changed

13 files changed

+32
-123
lines changed

Library/Homebrew/Gemfile

-5
Original file line numberDiff line numberDiff line change
@@ -81,8 +81,3 @@ gem "plist"
8181
gem "ruby-macho"
8282
gem "sorbet-runtime"
8383
gem "warning"
84-
85-
# TODO: remove when HOMEBREW_REQUIRED_RUBY_VERSION >= 2.7
86-
install_if -> { RUBY_VERSION < "2.7" } do
87-
gem "did_you_mean"
88-
end

Library/Homebrew/Gemfile.lock

-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ GEM
1818
commander (4.6.0)
1919
highline (~> 2.0.0)
2020
concurrent-ruby (1.2.2)
21-
did_you_mean (1.6.3)
2221
diff-lcs (1.5.0)
2322
docile (1.4.0)
2423
elftools (1.2.0)
@@ -193,7 +192,6 @@ DEPENDENCIES
193192
addressable
194193
bootsnap
195194
byebug
196-
did_you_mean
197195
json_schemer
198196
minitest
199197
parallel_tests

Library/Homebrew/brew.sh

-5
Original file line numberDiff line numberDiff line change
@@ -585,9 +585,6 @@ then
585585
HOMEBREW_FORCE_BREWED_GIT="1"
586586
fi
587587
fi
588-
589-
# System Ruby usage is deprecated. TODO: clean this up once 2.6 is fully ditched.
590-
unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
591588
else
592589
HOMEBREW_PRODUCT="${HOMEBREW_SYSTEM}brew"
593590
# Don't try to follow /etc/os-release
@@ -651,7 +648,6 @@ Your Git executable: $(unset git && type -p "${HOMEBREW_GIT}")"
651648
fi
652649

653650
HOMEBREW_LINUX_MINIMUM_GLIBC_VERSION="2.13"
654-
unset HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
655651

656652
HOMEBREW_CORE_REPOSITORY_ORIGIN="$("${HOMEBREW_GIT}" -C "${HOMEBREW_CORE_REPOSITORY}" remote get-url origin 2>/dev/null)"
657653
if [[ "${HOMEBREW_CORE_REPOSITORY_ORIGIN}" =~ (/linuxbrew|Linuxbrew/homebrew)-core(\.git)?$ ]]
@@ -742,7 +738,6 @@ export HOMEBREW_USER_AGENT
742738
export HOMEBREW_USER_AGENT_CURL
743739
export HOMEBREW_API_DEFAULT_DOMAIN
744740
export HOMEBREW_BOTTLE_DEFAULT_DOMAIN
745-
export HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH
746741
export HOMEBREW_CURL_SPEED_LIMIT
747742
export HOMEBREW_CURL_SPEED_TIME
748743

Library/Homebrew/dev-cmd/vendor-gems.rb

-3
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,6 @@ def vendor_gems
3333

3434
ENV["BUNDLE_WITH"] = Homebrew.valid_gem_groups.join(":")
3535

36-
# System Ruby does not pick up the correct SDK by default.
37-
ENV["SDKROOT"] = MacOS.sdk_path if ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"]
38-
3936
ohai "cd #{HOMEBREW_LIBRARY_PATH}"
4037
HOMEBREW_LIBRARY_PATH.cd do
4138
if args.update

Library/Homebrew/extend/os/mac/cleanup.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Cleanup
88
def use_system_ruby?
99
return false if Homebrew::EnvConfig.force_vendor_ruby?
1010

11-
ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"].present?
11+
Homebrew::EnvConfig.developer? && ENV["HOMEBREW_USE_RUBY_FROM_PATH"].present?
1212
end
1313
end
1414
end

Library/Homebrew/extend/os/mac/diagnostic.rb

-13
Original file line numberDiff line numberDiff line change
@@ -204,19 +204,6 @@ def check_if_xcode_needs_clt_installed
204204
EOS
205205
end
206206

207-
def check_ruby_version
208-
return unless ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"]
209-
return if RUBY_VERSION == HOMEBREW_REQUIRED_RUBY_VERSION
210-
return if Homebrew::EnvConfig.developer? && OS::Mac.version.prerelease?
211-
212-
<<~EOS
213-
Ruby version #{RUBY_VERSION} is unsupported on macOS #{MacOS.version}. Homebrew
214-
is developed and tested on Ruby #{HOMEBREW_REQUIRED_RUBY_VERSION}, and may not work correctly
215-
on other Rubies. Patches are accepted as long as they don't cause breakage
216-
on supported Rubies.
217-
EOS
218-
end
219-
220207
def check_xcode_prefix
221208
prefix = MacOS::Xcode.prefix
222209
return if prefix.nil?

Library/Homebrew/extend/os/mac/system_config.rb

+2-11
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,9 @@ module SystemConfig
77
class << self
88
include SystemCommand::Mixin
99

10-
undef describe_homebrew_ruby, describe_clang
11-
12-
def describe_homebrew_ruby
13-
s = describe_homebrew_ruby_version
14-
15-
if RUBY_PATH.to_s.match?(%r{^/System/Library/Frameworks/Ruby\.framework/Versions/[12]\.[089]/usr/bin/ruby})
16-
s
17-
else
18-
"#{s} => #{RUBY_PATH}"
19-
end
20-
end
10+
undef describe_clang
2111

12+
sig { returns(String) }
2213
def describe_clang
2314
return "N/A" if clang.null?
2415

Library/Homebrew/standalone/init.rb

-5
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,4 @@
4040
require_relative "../vendor/bundle/bundler/setup"
4141
$LOAD_PATH.unshift "#{HOMEBREW_LIBRARY_PATH}/vendor/bundle/#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/" \
4242
"bundler-#{Homebrew::HOMEBREW_BUNDLER_VERSION}/lib"
43-
if ruby_major == 2 && ruby_minor == 6
44-
# TEMP: Ruby 3 transition
45-
$LOAD_PATH.unshift "#{HOMEBREW_LIBRARY_PATH}/vendor/bundle/#{RUBY_ENGINE}/#{Gem.ruby_api_version}/gems/" \
46-
"did_you_mean-1.6.3/lib"
47-
end
4843
$LOAD_PATH.uniq!

Library/Homebrew/system_config.rb

+1-11
Original file line numberDiff line numberDiff line change
@@ -92,19 +92,9 @@ def describe_path(path)
9292
end
9393
end
9494

95-
sig { returns(String) }
96-
def describe_homebrew_ruby_version
97-
case RUBY_VERSION
98-
when /^1\.[89]/, /^2\.0/
99-
"#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}"
100-
else
101-
RUBY_VERSION
102-
end
103-
end
104-
10595
sig { returns(String) }
10696
def describe_homebrew_ruby
107-
"#{describe_homebrew_ruby_version} => #{RUBY_PATH}"
97+
"#{RUBY_VERSION} => #{RUBY_PATH}"
10898
end
10999

110100
sig { returns(T.nilable(String)) }

Library/Homebrew/test/dev-cmd/irb_spec.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
# TODO: newer Ruby only supports history saving in interactive sessions
3131
# and not if you feed in data from a file or stdin like we are doing here.
3232
# The test will need to be adjusted for this to work.
33-
expect(history_file).to exist if RUBY_VERSION < "2.7"
33+
# expect(history_file).to exist
3434
end
3535
end
3636
end

Library/Homebrew/test/os/mac/diagnostic_spec.rb

-11
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,6 @@
3030
.to match("Xcode alone is not sufficient on El Capitan")
3131
end
3232

33-
specify "#check_ruby_version" do
34-
macos_version = MacOSVersion.new("10.12")
35-
allow(OS::Mac).to receive(:version).and_return(macos_version)
36-
allow(OS::Mac).to receive(:full_version).and_return(macos_version)
37-
stub_const("RUBY_VERSION", "1.8.6")
38-
ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"] = "1"
39-
40-
expect(checks.check_ruby_version)
41-
.to match "Ruby version 1.8.6 is unsupported on macOS 10.12"
42-
end
43-
4433
describe "#check_if_supported_sdk_available" do
4534
let(:macos_version) { MacOSVersion.new("11") }
4635

Library/Homebrew/utils/gems.rb

+1-25
Original file line numberDiff line numberDiff line change
@@ -177,14 +177,6 @@ def install_bundler!
177177
def user_gem_groups
178178
@user_gem_groups ||= if GEM_GROUPS_FILE.exist?
179179
GEM_GROUPS_FILE.readlines(chomp: true)
180-
elsif RUBY_VERSION < "2.7"
181-
# Backwards compatibility. This elsif block removed by the end of 2023.
182-
# We will not support this in Ruby >=2.7.
183-
require "settings"
184-
groups = Homebrew::Settings.read(:gemgroups)&.split(";") || []
185-
write_user_gem_groups(groups)
186-
Homebrew::Settings.delete(:gemgroups)
187-
groups
188180
else
189181
[]
190182
end
@@ -213,14 +205,7 @@ def write_user_gem_groups(groups)
213205
end
214206

215207
def forget_user_gem_groups!
216-
if GEM_GROUPS_FILE.exist?
217-
GEM_GROUPS_FILE.truncate(0)
218-
elsif RUBY_VERSION < "2.7"
219-
# Backwards compatibility. This else block can be removed by the end of 2023.
220-
# We will not support this in Ruby >=2.7.
221-
require "settings"
222-
Homebrew::Settings.delete(:gemgroups)
223-
end
208+
GEM_GROUPS_FILE.truncate(0) if GEM_GROUPS_FILE.exist?
224209
@user_gem_groups = []
225210
end
226211

@@ -239,7 +224,6 @@ def install_bundler_gems!(only_warn_on_failure: false, setup_path: true, groups:
239224
old_bundle_gemfile = ENV.fetch("BUNDLE_GEMFILE", nil)
240225
old_bundle_with = ENV.fetch("BUNDLE_WITH", nil)
241226
old_bundle_frozen = ENV.fetch("BUNDLE_FROZEN", nil)
242-
old_sdkroot = ENV.fetch("SDKROOT", nil)
243227

244228
invalid_groups = groups - valid_gem_groups
245229
raise ArgumentError, "Invalid gem groups: #{invalid_groups.join(", ")}" unless invalid_groups.empty?
@@ -267,13 +251,6 @@ def install_bundler_gems!(only_warn_on_failure: false, setup_path: true, groups:
267251
ENV["BUNDLE_WITH"] = groups.join(" ")
268252
ENV["BUNDLE_FROZEN"] = "true"
269253

270-
# System Ruby does not pick up the correct SDK by default.
271-
if ENV["HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH"]
272-
macos_major = ENV.fetch("HOMEBREW_MACOS_VERSION").partition(".").first
273-
sdkroot = "/Library/Developer/CommandLineTools/SDKs/MacOSX#{macos_major}.sdk"
274-
ENV["SDKROOT"] = sdkroot if Dir.exist?(sdkroot)
275-
end
276-
277254
if @bundle_installed_groups != groups
278255
bundle = File.join(find_in_path("bundle"), "bundle")
279256
bundle_check_output = `#{bundle} check 2>&1`
@@ -367,6 +344,5 @@ def install_bundler_gems!(only_warn_on_failure: false, setup_path: true, groups:
367344
ENV["BUNDLE_WITH"] = old_bundle_with
368345
ENV["BUNDLE_FROZEN"] = old_bundle_frozen
369346
end
370-
ENV["SDKROOT"] = old_sdkroot
371347
end
372348
end

Library/Homebrew/utils/ruby.sh

+26-30
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ test_ruby() {
1818
"${HOMEBREW_REQUIRED_RUBY_VERSION}" 2>/dev/null
1919
}
2020

21+
system_ruby_supported() {
22+
([[ -z "${HOMEBREW_MACOS}" ]] || can_use_ruby_from_path)
23+
}
24+
2125
can_use_ruby_from_path() {
2226
if [[ -n "${HOMEBREW_DEVELOPER}" || -n "${HOMEBREW_TESTS}" ]] && [[ -n "${HOMEBREW_USE_RUBY_FROM_PATH}" ]]
2327
then
@@ -39,47 +43,37 @@ find_first_valid_ruby() {
3943
done
4044
}
4145

42-
# HOMEBREW_MACOS is set by brew.sh
4346
# HOMEBREW_PATH is set by global.rb
4447
# shellcheck disable=SC2154
4548
find_ruby() {
46-
if [[ -n "${HOMEBREW_MACOS}" ]] && ! can_use_ruby_from_path
47-
then
48-
echo "/System/Library/Frameworks/Ruby.framework/Versions/Current/usr/bin/ruby"
49-
else
50-
local valid_ruby
49+
local valid_ruby
5150

52-
# Prioritise rubies from the filtered path (/usr/bin etc) unless explicitly overridden.
53-
if ! can_use_ruby_from_path
54-
then
55-
# function which() is set by brew.sh
56-
# it is aliased to `type -P`
57-
# shellcheck disable=SC2230
58-
valid_ruby=$(find_first_valid_ruby < <(which -a ruby))
59-
fi
60-
61-
if [[ -z "${valid_ruby}" ]]
62-
then
63-
# Same as above
64-
# shellcheck disable=SC2230
65-
valid_ruby=$(find_first_valid_ruby < <(PATH="${HOMEBREW_PATH}" which -a ruby))
66-
fi
51+
# Prioritise rubies from the filtered path (/usr/bin etc) unless explicitly overridden.
52+
if ! can_use_ruby_from_path
53+
then
54+
# function which() is set by brew.sh
55+
# it is aliased to `type -P`
56+
# shellcheck disable=SC2230
57+
valid_ruby=$(find_first_valid_ruby < <(which -a ruby))
58+
fi
6759

68-
echo "${valid_ruby}"
60+
if [[ -z "${valid_ruby}" ]]
61+
then
62+
# Same as above
63+
# shellcheck disable=SC2230
64+
valid_ruby=$(find_first_valid_ruby < <(PATH="${HOMEBREW_PATH}" which -a ruby))
6965
fi
66+
67+
echo "${valid_ruby}"
7068
}
7169

7270
# HOMEBREW_FORCE_VENDOR_RUBY is from the user environment
73-
# HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH are set by brew.sh
7471
# shellcheck disable=SC2154
7572
need_vendored_ruby() {
7673
if [[ -n "${HOMEBREW_FORCE_VENDOR_RUBY}" ]]
7774
then
7875
return 0
79-
elif [[ -n "${HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH}" ]] && ! can_use_ruby_from_path
80-
then
81-
return 1
82-
elif ([[ -z "${HOMEBREW_MACOS}" ]] || can_use_ruby_from_path) && test_ruby "${HOMEBREW_RUBY_PATH}"
76+
elif system_ruby_supported && test_ruby "${HOMEBREW_RUBY_PATH}"
8377
then
8478
return 1
8579
else
@@ -96,8 +90,6 @@ setup-ruby-path() {
9690
local vendor_ruby_terminfo
9791
local vendor_ruby_latest_version
9892
local vendor_ruby_current_version
99-
# When bumping check if HOMEBREW_MACOS_SYSTEM_RUBY_NEW_ENOUGH (in brew.sh)
100-
# also needs to be changed.
10193
local ruby_exec
10294
local upgrade_fail
10395
local install_fail
@@ -140,7 +132,11 @@ If there's no Homebrew Portable Ruby available for your processor:
140132
brew vendor-install ruby || odie "${upgrade_fail}"
141133
fi
142134
else
143-
HOMEBREW_RUBY_PATH="$(find_ruby)"
135+
if system_ruby_supported
136+
then
137+
HOMEBREW_RUBY_PATH="$(find_ruby)"
138+
fi
139+
144140
if need_vendored_ruby
145141
then
146142
brew vendor-install ruby || odie "${install_fail}"

0 commit comments

Comments
 (0)