Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions bundler/lib/bundler/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,7 @@ def normalize_options(name, version, opts)
next if VALID_PLATFORMS.include?(p)
raise GemfileError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}"
end
deprecate_legacy_windows_platforms(platforms)

# Save sources passed in a key
if opts.key?("source")
Expand Down Expand Up @@ -493,6 +494,16 @@ def normalize_source(source)
end
end

def deprecate_legacy_windows_platforms(platforms)
windows_platforms = platforms.select {|pl| pl.to_s.match?(/mingw|mswin/) }
return if windows_platforms.empty?

windows_platforms = windows_platforms.map! {|pl| ":#{pl}" }.join(", ")
message = "Platform #{windows_platforms} is deprecated. Please use platform :windows instead."
removed_message = "Platform #{windows_platforms} has been removed. Please use platform :windows instead."
Bundler::SharedHelpers.major_deprecation 2, message, removed_message: removed_message
end

def check_path_source_safety
return if @sources.global_path_source.nil?

Expand Down
14 changes: 14 additions & 0 deletions bundler/spec/bundler/dsl_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,11 @@
to raise_error(Bundler::GemfileError, /is not a valid platform/)
end

it "raises a deprecation warning for legacy windows platforms" do
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, /\APlatform :mswin, :x64_mingw is deprecated/, removed_message: /\APlatform :mswin, :x64_mingw has been removed/)
subject.gem("foo", platforms: [:mswin, :jruby, :x64_mingw])
end

it "rejects empty gem name" do
expect { subject.gem("") }.
to raise_error(Bundler::GemfileError, /an empty gem name is not valid/)
Expand Down Expand Up @@ -285,6 +290,15 @@
end
end

describe "#platforms" do
it "raises a deprecation warning for legacy windows platforms" do
expect(Bundler::SharedHelpers).to receive(:major_deprecation).with(2, /\APlatform :mswin64, :mingw is deprecated/, removed_message: /\APlatform :mswin64, :mingw has been removed/)
subject.platforms(:mswin64, :jruby, :mingw) do
subject.gem("foo")
end
end
end

context "can bundle groups of gems with" do
# git "https://github.com/rails/rails.git" do
# gem "railties"
Expand Down
14 changes: 13 additions & 1 deletion bundler/spec/commands/cache_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -221,16 +221,28 @@
expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).to exist
end

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

bundle "cache --all-platforms"
expect(err).to include("deprecated")
expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).to exist
end

it "prints an error when using legacy windows rubies", bundler: "3" do
gemfile <<-D
source "https://gem.repo1"
gem 'myrack', :platforms => [:ruby_20, :x64_mingw_20]
D

bundle "cache --all-platforms", raise_on_error: false
expect(err).to include("removed")
expect(bundled_app("vendor/cache/myrack-1.0.0.gem")).not_to exist
end

it "does not attempt to install gems in without groups" do
build_repo4 do
build_gem "uninstallable", "2.0" do |s|
Expand Down
2 changes: 1 addition & 1 deletion bundler/spec/install/gemfile/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@
gemfile <<-G
source "https://gem.repo1"

gem "myrack", :platform => [:windows, :mswin, :mswin64, :mingw, :x64_mingw, :jruby]
gem "myrack", :platform => [:windows, :jruby]
G

bundle "install"
Expand Down
2 changes: 1 addition & 1 deletion bundler/spec/install/gemfile/specific_platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1000,7 +1000,7 @@

gem "nokogiri"

gem "tzinfo", "~> 1.2", platforms: %i[mingw mswin x64_mingw jruby]
gem "tzinfo", "~> 1.2", platforms: %i[windows jruby]
G

checksums = checksums_section_when_enabled do |c|
Expand Down
2 changes: 1 addition & 1 deletion bundler/spec/runtime/platform_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@
simulate_platform "x86-mswin32" do
install_gemfile <<-G
source "https://gem.repo1"
gem "nokogiri", :platforms => [:windows, :mswin, :mswin64, :mingw, :x64_mingw, :jruby]
gem "nokogiri", :platforms => [:windows, :jruby]
gem "platform_specific"
G

Expand Down
Loading