Skip to content

Commit e11401f

Browse files
johnnyshieldshsbt
authored andcommitted
[rubygems/rubygems] Deprecate legacy windows platforms (mswin, mingw) in the Bundler DSL, in favor of using platform :windows
This commit is only deprecation and does not change/remove any actual functionality. ruby/rubygems@0ca6dc3984
1 parent 91a17fb commit e11401f

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

lib/bundler/dsl.rb

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,7 @@ def normalize_options(name, version, opts)
413413
next if VALID_PLATFORMS.include?(p)
414414
raise GemfileError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}"
415415
end
416+
deprecate_legacy_windows_platforms(platforms)
416417

417418
# Save sources passed in a key
418419
if opts.key?("source")
@@ -493,6 +494,16 @@ def normalize_source(source)
493494
end
494495
end
495496

497+
def deprecate_legacy_windows_platforms(platforms)
498+
windows_platforms = platforms.select {|pl| pl.to_s.match?(/mingw|mswin/) }
499+
return if windows_platforms.empty?
500+
501+
windows_platforms = windows_platforms.map! {|pl| ":#{pl}" }.join(", ")
502+
message = "Platform #{windows_platforms} is deprecated. Please use platform :windows instead."
503+
removed_message = "Platform #{windows_platforms} has been removed. Please use platform :windows instead."
504+
Bundler::SharedHelpers.major_deprecation 2, message, removed_message: removed_message
505+
end
506+
496507
def check_path_source_safety
497508
return if @sources.global_path_source.nil?
498509

spec/bundler/bundler/dsl_spec.rb

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,11 @@
221221
to raise_error(Bundler::GemfileError, /is not a valid platform/)
222222
end
223223

224+
it "raises a deprecation warning for legacy windows platforms" do
225+
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, /\APlatform :mswin, :x64_mingw is deprecated/, removed_message: /\APlatform :mswin, :x64_mingw has been removed/)
226+
subject.gem("foo", platforms: [:mswin, :jruby, :x64_mingw])
227+
end
228+
224229
it "rejects empty gem name" do
225230
expect { subject.gem("") }.
226231
to raise_error(Bundler::GemfileError, /an empty gem name is not valid/)
@@ -285,6 +290,15 @@
285290
end
286291
end
287292

293+
describe "#platforms" do
294+
it "raises a deprecation warning for legacy windows platforms" do
295+
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, /\APlatform :mswin64, :mingw is deprecated/, removed_message: /\APlatform :mswin64, :mingw has been removed/)
296+
subject.platforms(:mswin64, :jruby, :mingw) do
297+
subject.gem("foo")
298+
end
299+
end
300+
end
301+
288302
context "can bundle groups of gems with" do
289303
# git "https://github.com/rails/rails.git" do
290304
# gem "railties"

spec/bundler/commands/cache_spec.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,16 +221,28 @@
221221
expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).to exist
222222
end
223223

224-
it "puts the gems in vendor/cache even for legacy windows rubies" do
224+
it "puts the gems in vendor/cache even for legacy windows rubies, but prints a warning", bundler: "< 3" do
225225
gemfile <<-D
226226
source "https://gem.repo1"
227227
gem 'myrack', :platforms => [:ruby_20, :x64_mingw_20]
228228
D
229229

230230
bundle "cache --all-platforms"
231+
expect(err).to include("deprecated")
231232
expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).to exist
232233
end
233234

235+
it "prints an error when using legacy windows rubies", bundler: "3" do
236+
gemfile <<-D
237+
source "https://gem.repo1"
238+
gem 'myrack', :platforms => [:ruby_20, :x64_mingw_20]
239+
D
240+
241+
bundle "cache --all-platforms", raise_on_error: false
242+
expect(err).to include("removed")
243+
expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).not_to exist
244+
end
245+
234246
it "does not attempt to install gems in without groups" do
235247
build_repo4 do
236248
build_gem "uninstallable", "2.0" do |s|

0 commit comments

Comments
 (0)