Skip to content

Commit f92d2c9

Browse files
committed
Deprecate CurrentRuby#maglev? and other related maglev methods:
- Follow up to #8430 (comment). The maglev platform was not supported by Bundler, so calling `gem "foo", platforms: ["maglev"]` would raise an error. The helpers added in the `CurrentRuby` class were used at a time when maglev was supported (as explained in 45ec86e). Support of maglev was most likely dropped at some point and the helpers in the `CurrentRuby` class were not deprecated/removed. We decided to deprecate them now.
1 parent 658f7a9 commit f92d2c9

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

bundler/lib/bundler/current_ruby.rb

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,18 @@ def jruby?
5050
end
5151

5252
def maglev?
53+
message =
54+
"`CurrentRuby#maglev?` is deprecated with no replacement. Please use the " \
55+
"built-in Ruby `RUBY_ENGINE` constant to check the Ruby implementation you are running on."
56+
removed_message =
57+
"`CurrentRuby#maglev?` was removed with no replacement. Please use the " \
58+
"built-in Ruby `RUBY_ENGINE` constant to check the Ruby implementation you are running on."
59+
internally_exempted = caller_locations(1, 1).first.path == __FILE__
60+
61+
unless internally_exempted
62+
SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
63+
end
64+
5365
RUBY_ENGINE == "maglev"
5466
end
5567

@@ -71,9 +83,21 @@ def windows?
7183
RUBY_VERSION.start_with?("#{version}.")
7284
end
7385

74-
all_platforms = PLATFORM_MAP.keys << "maglev"
86+
deprecated_maglev_platform = "maglev"
87+
all_platforms = PLATFORM_MAP.keys << deprecated_maglev_platform
7588
all_platforms.each do |platform|
7689
define_method(:"#{platform}_#{trimmed_version}?") do
90+
if platform == deprecated_maglev_platform
91+
message =
92+
"`CurrentRuby##{__method__}` is deprecated with no replacement. Please use the " \
93+
"built-in Ruby `RUBY_ENGINE` and `RUBY_VERSION` constants to perform a similar check."
94+
removed_message =
95+
"`CurrentRuby##{__method__}` was removed with no replacement. Please use the " \
96+
"built-in Ruby `RUBY_ENGINE` and `RUBY_VERSION` constants to perform a similar check."
97+
98+
SharedHelpers.major_deprecation(2, message, removed_message: removed_message, print_caller_location: true)
99+
end
100+
77101
send(:"#{platform}?") && send(:"on_#{trimmed_version}?")
78102
end
79103
end

bundler/spec/bundler/current_ruby_spec.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,20 @@
137137
expect(subject).to eq(platforms.merge(deprecated))
138138
end
139139
end
140+
141+
describe "Deprecated platform" do
142+
it "Outputs a deprecation warning when calling maglev?", bundler: "< 3" do
143+
expect(Bundler.ui).to receive(:warn).with(/`CurrentRuby#maglev\?` is deprecated with no replacement./)
144+
145+
Bundler.current_ruby.maglev?
146+
end
147+
148+
it "Outputs a deprecation warning when calling maglev_31?", bundler: "< 3" do
149+
expect(Bundler.ui).to receive(:warn).with(/`CurrentRuby#maglev_31\?` is deprecated with no replacement./)
150+
151+
Bundler.current_ruby.maglev_31?
152+
end
153+
154+
pending "is removed and shows a helpful error message about it", bundler: "3"
155+
end
140156
end

0 commit comments

Comments
 (0)