diff options
Diffstat (limited to 'spec')
21 files changed, 394 insertions, 164 deletions
diff --git a/spec/bundler/bundler/definition_spec.rb b/spec/bundler/bundler/definition_spec.rb index 2618786e7c..13688c2b3d 100644 --- a/spec/bundler/bundler/definition_spec.rb +++ b/spec/bundler/bundler/definition_spec.rb @@ -136,7 +136,7 @@ RSpec.describe Bundler::Definition do only_java (1.1-java) PLATFORMS - #{lockfile_platforms_for(["java"] + local_platforms)} + #{lockfile_platforms_for(["java", specific_local_platform])} DEPENDENCIES only_java diff --git a/spec/bundler/commands/lock_spec.rb b/spec/bundler/commands/lock_spec.rb index 11f96315ca..b20a6ded43 100644 --- a/spec/bundler/commands/lock_spec.rb +++ b/spec/bundler/commands/lock_spec.rb @@ -217,7 +217,7 @@ RSpec.describe "bundle lock" do allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq) + expect(lockfile.platforms).to match_array([java, mingw, specific_local_platform].uniq) end it "supports adding new platforms with force_ruby_platform = true" do @@ -249,7 +249,7 @@ RSpec.describe "bundle lock" do allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to match_array(local_platforms.unshift("ruby").uniq) + expect(lockfile.platforms).to match_array(["ruby", specific_local_platform].uniq) end it "warns when adding an unknown platform" do @@ -262,16 +262,16 @@ RSpec.describe "bundle lock" do allow(Bundler::SharedHelpers).to receive(:find_gemfile).and_return(bundled_app_gemfile) lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to match_array(local_platforms.unshift(java, mingw).uniq) + expect(lockfile.platforms).to match_array([java, mingw, specific_local_platform].uniq) bundle "lock --remove-platform java" lockfile = Bundler::LockfileParser.new(read_lockfile) - expect(lockfile.platforms).to match_array(local_platforms.unshift(mingw).uniq) + expect(lockfile.platforms).to match_array([mingw, specific_local_platform].uniq) end it "errors when removing all platforms" do - bundle "lock --remove-platform #{local_platforms.join(" ")}", :raise_on_error => false + bundle "lock --remove-platform #{specific_local_platform}", :raise_on_error => false expect(err).to include("Removing all platforms from the bundle is not allowed") end diff --git a/spec/bundler/commands/outdated_spec.rb b/spec/bundler/commands/outdated_spec.rb index 121e39f55a..d0209022a2 100644 --- a/spec/bundler/commands/outdated_spec.rb +++ b/spec/bundler/commands/outdated_spec.rb @@ -821,7 +821,7 @@ RSpec.describe "bundle outdated" do expect(out).to end_with("Bundle up to date!") end - it "reports that updates are available if the JRuby platform is used", :jruby do + it "reports that updates are available if the JRuby platform is used", :jruby_only do install_gemfile <<-G source "#{file_uri_for(gem_repo2)}" gem "laduradura", '= 5.15.2', :platforms => [:ruby, :jruby] diff --git a/spec/bundler/install/gemfile/force_ruby_platform_spec.rb b/spec/bundler/install/gemfile/force_ruby_platform_spec.rb new file mode 100644 index 0000000000..0e9f1f0292 --- /dev/null +++ b/spec/bundler/install/gemfile/force_ruby_platform_spec.rb @@ -0,0 +1,118 @@ +# frozen_string_literal: true + +RSpec.describe "bundle install with force_ruby_platform DSL option", :jruby do + context "when no transitive deps" do + before do + build_repo4 do + # Build a gem with platform specific versions + build_gem("platform_specific") do |s| + s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 RUBY'" + end + + build_gem("platform_specific") do |s| + s.platform = Bundler.local_platform + s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 #{Bundler.local_platform}'" + end + + # Build the exact same gem with a different name to compare using vs not using the option + build_gem("platform_specific_forced") do |s| + s.write "lib/platform_specific_forced.rb", "PLATFORM_SPECIFIC_FORCED = '1.0.0 RUBY'" + end + + build_gem("platform_specific_forced") do |s| + s.platform = Bundler.local_platform + s.write "lib/platform_specific_forced.rb", "PLATFORM_SPECIFIC_FORCED = '1.0.0 #{Bundler.local_platform}'" + end + end + end + + it "pulls the pure ruby variant of the given gem" do + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + + gem "platform_specific_forced", :force_ruby_platform => true + gem "platform_specific" + G + + expect(the_bundle).to include_gems "platform_specific_forced 1.0.0 RUBY" + expect(the_bundle).to include_gems "platform_specific 1.0.0 #{Bundler.local_platform}" + end + + it "still respects a global `force_ruby_platform` config" do + install_gemfile <<-G, :env => { "BUNDLE_FORCE_RUBY_PLATFORM" => "true" } + source "#{file_uri_for(gem_repo4)}" + + gem "platform_specific_forced", :force_ruby_platform => true + gem "platform_specific" + G + + expect(the_bundle).to include_gems "platform_specific_forced 1.0.0 RUBY" + expect(the_bundle).to include_gems "platform_specific 1.0.0 RUBY" + end + end + + context "when also a transitive dependency" do + before do + build_repo4 do + build_gem("depends_on_platform_specific") {|s| s.add_runtime_dependency "platform_specific" } + + build_gem("platform_specific") do |s| + s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 RUBY'" + end + + build_gem("platform_specific") do |s| + s.platform = Bundler.local_platform + s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 #{Bundler.local_platform}'" + end + end + end + + it "still pulls the ruby variant" do + install_gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + + gem "depends_on_platform_specific" + gem "platform_specific", :force_ruby_platform => true + G + + expect(the_bundle).to include_gems "platform_specific 1.0.0 RUBY" + end + end + + context "with transitive dependencies with platform specific versions" do + before do + build_repo4 do + build_gem("depends_on_platform_specific") do |s| + s.add_runtime_dependency "platform_specific" + s.write "lib/depends_on_platform_specific.rb", "DEPENDS_ON_PLATFORM_SPECIFIC = '1.0.0 RUBY'" + end + + build_gem("depends_on_platform_specific") do |s| + s.add_runtime_dependency "platform_specific" + s.platform = Bundler.local_platform + s.write "lib/depends_on_platform_specific.rb", "DEPENDS_ON_PLATFORM_SPECIFIC = '1.0.0 #{Bundler.local_platform}'" + end + + build_gem("platform_specific") do |s| + s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 RUBY'" + end + + build_gem("platform_specific") do |s| + s.platform = Bundler.local_platform + s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 #{Bundler.local_platform}'" + end + end + end + + it "ignores ruby variants for the transitive dependencies" do + install_gemfile <<-G, :env => { "DEBUG_RESOLVER" => "true" } + source "#{file_uri_for(gem_repo4)}" + + gem "depends_on_platform_specific", :force_ruby_platform => true + G + + expect(the_bundle).to include_gems "depends_on_platform_specific 1.0.0 RUBY" + expect(the_bundle).to include_gems "platform_specific 1.0.0 #{Bundler.local_platform}" + end + end +end diff --git a/spec/bundler/install/gemfile/gemspec_spec.rb b/spec/bundler/install/gemfile/gemspec_spec.rb index 6bcfadab7e..941f1c6db9 100644 --- a/spec/bundler/install/gemfile/gemspec_spec.rb +++ b/spec/bundler/install/gemfile/gemspec_spec.rb @@ -8,6 +8,26 @@ RSpec.describe "bundle install from an existing gemspec" do end end + let(:x64_mingw_archs) do + if RUBY_PLATFORM == "x64-mingw-ucrt" + if Gem.rubygems_version >= Gem::Version.new("3.2.28") + ["x64-mingw-ucrt", "x64-mingw32"] + else + ["x64-mingw32", "x64-unknown"] + end + else + ["x64-mingw32"] + end + end + + let(:x64_mingw_gems) do + x64_mingw_archs.map {|p| "platform_specific (1.0-#{p})" }.join("\n ") + end + + let(:x64_mingw_platforms) do + x64_mingw_archs.join("\n ") + end + it "should install runtime and development dependencies" do build_lib("foo", :path => tmp.join("foo")) do |s| s.write("Gemfile", "source :rubygems\ngemspec") @@ -168,7 +188,7 @@ RSpec.describe "bundle install from an existing gemspec" do expect(out.scan(message).size).to eq(1) end - it "should match a lockfile on non-ruby platforms with a transitive platform dependency", :jruby do + it "should match a lockfile on non-ruby platforms with a transitive platform dependency", :jruby_only do build_lib("foo", :path => tmp.join("foo")) do |s| s.add_dependency "platform_specific" end @@ -328,83 +348,65 @@ RSpec.describe "bundle install from an existing gemspec" do context "with a lockfile and some missing dependencies" do let(:source_uri) { "http://localgemserver.test" } - context "previously bundled for Ruby" do - let(:platform) { "ruby" } - - before do - skip "not installing for some reason" if Gem.win_platform? - - build_lib("foo", :path => tmp.join("foo")) do |s| - s.add_dependency "rack", "=1.0.0" - end - - gemfile <<-G - source "#{source_uri}" - gemspec :path => "../foo" - G + before do + build_lib("foo", :path => tmp.join("foo")) do |s| + s.add_dependency "rack", "=1.0.0" + end - lockfile <<-L - PATH - remote: ../foo - specs: - foo (1.0) - rack (= 1.0.0) + gemfile <<-G + source "#{source_uri}" + gemspec :path => "../foo" + G - GEM - remote: #{source_uri} - specs: - rack (1.0.0) + lockfile <<-L + PATH + remote: ../foo + specs: + foo (1.0) + rack (= 1.0.0) - PLATFORMS - #{generic_local_platform} + GEM + remote: #{source_uri} + specs: + rack (1.0.0) - DEPENDENCIES - foo! + PLATFORMS + #{generic_local_platform} - BUNDLED WITH - #{Bundler::VERSION} - L - end + DEPENDENCIES + foo! - context "using JRuby with explicit platform", :jruby do - before do - create_file( - tmp.join("foo", "foo-java.gemspec"), - build_spec("foo", "1.0", "java") do - dep "rack", "=1.0.0" - @spec.authors = "authors" - @spec.summary = "summary" - end.first.to_ruby - ) - end + BUNDLED WITH + #{Bundler::VERSION} + L + end - it "should install" do - results = bundle "install", :artifice => "endpoint" - expect(results).to include("Installing rack 1.0.0") - expect(the_bundle).to include_gems "rack 1.0.0" - end + context "using JRuby with explicit platform", :jruby_only do + before do + create_file( + tmp.join("foo", "foo-java.gemspec"), + build_spec("foo", "1.0", "java") do + dep "rack", "=1.0.0" + @spec.authors = "authors" + @spec.summary = "summary" + end.first.to_ruby + ) end - context "using JRuby", :jruby do - it "should install" do - results = bundle "install", :artifice => "endpoint" - expect(results).to include("Installing rack 1.0.0") - expect(the_bundle).to include_gems "rack 1.0.0" - end + it "should install" do + results = bundle "install", :artifice => "endpoint" + expect(results).to include("Installing rack 1.0.0") + expect(the_bundle).to include_gems "rack 1.0.0" end + end - context "using Windows" do - it "should install" do - simulate_windows do - results = bundle "install", :artifice => "endpoint" - expect(results).to include("Installing rack 1.0.0") - expect(the_bundle).to include_gems "rack 1.0.0" - end - end - end + it "should install", :jruby do + results = bundle "install", :artifice => "endpoint" + expect(results).to include("Installing rack 1.0.0") + expect(the_bundle).to include_gems "rack 1.0.0" end - context "bundled for ruby and jruby" do + context "bundled for multiple platforms" do let(:platform_specific_type) { :runtime } let(:dependency) { "platform_specific" } before do @@ -434,6 +436,7 @@ RSpec.describe "bundle install from an existing gemspec" do simulate_new_machine simulate_platform("jruby") { bundle "install" } + simulate_platform(x64_mingw) { bundle "install" } end context "on ruby" do @@ -443,7 +446,7 @@ RSpec.describe "bundle install from an existing gemspec" do end context "as a runtime dependency" do - it "keeps java dependencies in the lockfile" do + it "keeps all platform dependencies in the lockfile" do expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY" expect(lockfile).to eq strip_whitespace(<<-L) PATH @@ -457,10 +460,12 @@ RSpec.describe "bundle install from an existing gemspec" do specs: platform_specific (1.0) platform_specific (1.0-java) + #{x64_mingw_gems} PLATFORMS java ruby + #{x64_mingw_platforms} DEPENDENCIES foo! @@ -474,7 +479,7 @@ RSpec.describe "bundle install from an existing gemspec" do context "as a development dependency" do let(:platform_specific_type) { :development } - it "keeps java dependencies in the lockfile" do + it "keeps all platform dependencies in the lockfile" do expect(the_bundle).to include_gems "foo 1.0", "platform_specific 1.0 RUBY" expect(lockfile).to eq strip_whitespace(<<-L) PATH @@ -487,10 +492,12 @@ RSpec.describe "bundle install from an existing gemspec" do specs: platform_specific (1.0) platform_specific (1.0-java) + #{x64_mingw_gems} PLATFORMS java ruby + #{x64_mingw_platforms} DEPENDENCIES foo! @@ -506,7 +513,7 @@ RSpec.describe "bundle install from an existing gemspec" do let(:platform_specific_type) { :development } let(:dependency) { "indirect_platform_specific" } - it "keeps java dependencies in the lockfile" do + it "keeps all platform dependencies in the lockfile" do expect(the_bundle).to include_gems "foo 1.0", "indirect_platform_specific 1.0", "platform_specific 1.0 RUBY" expect(lockfile).to eq strip_whitespace(<<-L) PATH @@ -521,10 +528,12 @@ RSpec.describe "bundle install from an existing gemspec" do platform_specific platform_specific (1.0) platform_specific (1.0-java) + #{x64_mingw_gems} PLATFORMS java ruby + #{x64_mingw_platforms} DEPENDENCIES foo! @@ -608,7 +617,7 @@ RSpec.describe "bundle install from an existing gemspec" do PLATFORMS ruby - x64-mingw32 + #{x64_mingw_platforms} x86-mingw32 DEPENDENCIES @@ -665,7 +674,7 @@ RSpec.describe "bundle install from an existing gemspec" do railties (6.1.4) PLATFORMS - #{lockfile_platforms_for(["java"] + local_platforms)} + #{lockfile_platforms_for(["java", specific_local_platform])} DEPENDENCIES activeadmin! diff --git a/spec/bundler/install/gemfile/git_spec.rb b/spec/bundler/install/gemfile/git_spec.rb index 2c2d4f91d8..3f8a5afc40 100644 --- a/spec/bundler/install/gemfile/git_spec.rb +++ b/spec/bundler/install/gemfile/git_spec.rb @@ -92,7 +92,7 @@ RSpec.describe "bundle install with git sources" do expect(err).to include("The source contains the following gems matching 'foo':\n * foo-1.0") end - it "complains with version and platform if pinned specs don't exist in the git repo", :jruby do + it "complains with version and platform if pinned specs don't exist in the git repo", :jruby_only do build_git "only_java" do |s| s.platform = "java" end @@ -107,7 +107,7 @@ RSpec.describe "bundle install with git sources" do expect(err).to include("The source contains the following gems matching 'only_java':\n * only_java-1.0-java") end - it "complains with multiple versions and platforms if pinned specs don't exist in the git repo", :jruby do + it "complains with multiple versions and platforms if pinned specs don't exist in the git repo", :jruby_only do build_git "only_java", "1.0" do |s| s.platform = "java" end diff --git a/spec/bundler/install/gemfile/platform_spec.rb b/spec/bundler/install/gemfile/platform_spec.rb index 68d794ed84..a357a92272 100644 --- a/spec/bundler/install/gemfile/platform_spec.rb +++ b/spec/bundler/install/gemfile/platform_spec.rb @@ -50,7 +50,7 @@ RSpec.describe "bundle install across platforms" do expect(the_bundle).to include_gems "platform_specific 1.0 JAVA" end - it "pulls the pure ruby version on jruby if the java platform is not present in the lockfile and bundler is run in frozen mode", :jruby do + it "pulls the pure ruby version on jruby if the java platform is not present in the lockfile and bundler is run in frozen mode", :jruby_only do lockfile <<-G GEM remote: #{file_uri_for(gem_repo1)} @@ -216,28 +216,28 @@ RSpec.describe "bundle install across platforms" do pry BUNDLED WITH - #{Bundler::VERSION} + 1.16.1 L aggregate_failures do lockfile bad_lockfile - bundle :install + bundle :install, :env => { "BUNDLER_VERSION" => Bundler::VERSION } expect(lockfile).to eq good_lockfile lockfile bad_lockfile - bundle :update, :all => true + bundle :update, :all => true, :env => { "BUNDLER_VERSION" => Bundler::VERSION } expect(lockfile).to eq good_lockfile lockfile bad_lockfile - bundle "update ffi" + bundle "update ffi", :env => { "BUNDLER_VERSION" => Bundler::VERSION } expect(lockfile).to eq good_lockfile lockfile bad_lockfile - bundle "update empyrean" + bundle "update empyrean", :env => { "BUNDLER_VERSION" => Bundler::VERSION } expect(lockfile).to eq good_lockfile lockfile bad_lockfile - bundle :lock + bundle :lock, :env => { "BUNDLER_VERSION" => Bundler::VERSION } expect(lockfile).to eq good_lockfile end end @@ -332,8 +332,6 @@ end RSpec.describe "bundle install with platform conditionals" do it "installs gems tagged w/ the current platforms" do - skip "platform issues" if Gem.win_platform? - install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -402,8 +400,6 @@ RSpec.describe "bundle install with platform conditionals" do end it "installs gems tagged w/ the current platforms inline" do - skip "platform issues" if Gem.win_platform? - install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "nokogiri", :platforms => :#{local_tag} @@ -422,8 +418,6 @@ RSpec.describe "bundle install with platform conditionals" do end it "installs gems tagged w/ the current platform inline" do - skip "platform issues" if Gem.win_platform? - install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "nokogiri", :platform => :#{local_tag} diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb index 3e5a0a6270..276a84f2a6 100644 --- a/spec/bundler/install/gemfile/specific_platform_spec.rb +++ b/spec/bundler/install/gemfile/specific_platform_spec.rb @@ -250,10 +250,11 @@ RSpec.describe "bundle install with specific platforms" do end end - it "installs sorbet-static, which does not provide a pure ruby variant, just fine on truffleruby", :truffleruby do + it "installs sorbet-static, which does not provide a pure ruby variant, just fine", :truffleruby do + skip "does not apply to Windows" if Gem.win_platform? + build_repo2 do - build_gem("sorbet-static", "0.5.6403") {|s| s.platform = "x86_64-linux" } - build_gem("sorbet-static", "0.5.6403") {|s| s.platform = "universal-darwin-20" } + build_gem("sorbet-static", "0.5.6403") {|s| s.platform = Bundler.local_platform } end gemfile <<~G @@ -266,8 +267,7 @@ RSpec.describe "bundle install with specific platforms" do GEM remote: #{file_uri_for(gem_repo2)}/ specs: - sorbet-static (0.5.6403-universal-darwin-20) - sorbet-static (0.5.6403-x86_64-linux) + sorbet-static (0.5.6403-#{Bundler.local_platform}) PLATFORMS ruby @@ -283,19 +283,19 @@ RSpec.describe "bundle install with specific platforms" do end it "does not resolve if the current platform does not match any of available platform specific variants for a top level dependency" do - build_repo2 do + build_repo4 do build_gem("sorbet-static", "0.5.6433") {|s| s.platform = "x86_64-linux" } build_gem("sorbet-static", "0.5.6433") {|s| s.platform = "universal-darwin-20" } end gemfile <<~G - source "#{file_uri_for(gem_repo2)}" + source "#{file_uri_for(gem_repo4)}" gem "sorbet-static", "0.5.6433" G error_message = <<~ERROR.strip - Could not find gem 'sorbet-static (= 0.5.6433) arm64-darwin-21' in rubygems repository #{file_uri_for(gem_repo2)}/ or installed locally. + Could not find gem 'sorbet-static (= 0.5.6433)' with platform 'arm64-darwin-21' in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally. The source contains the following gems matching 'sorbet-static (= 0.5.6433)': * sorbet-static-0.5.6433-universal-darwin-20 @@ -303,7 +303,7 @@ RSpec.describe "bundle install with specific platforms" do ERROR simulate_platform "arm64-darwin-21" do - bundle "install", :raise_on_error => false + bundle "lock", :raise_on_error => false end expect(err).to include(error_message).once @@ -311,27 +311,27 @@ RSpec.describe "bundle install with specific platforms" do # Make sure it doesn't print error twice in verbose mode simulate_platform "arm64-darwin-21" do - bundle "install --verbose", :raise_on_error => false + bundle "lock --verbose", :raise_on_error => false end expect(err).to include(error_message).once end it "does not resolve if the current platform does not match any of available platform specific variants for a transitive dependency" do - build_repo2 do + build_repo4 do build_gem("sorbet", "0.5.6433") {|s| s.add_dependency "sorbet-static", "= 0.5.6433" } build_gem("sorbet-static", "0.5.6433") {|s| s.platform = "x86_64-linux" } build_gem("sorbet-static", "0.5.6433") {|s| s.platform = "universal-darwin-20" } end gemfile <<~G - source "#{file_uri_for(gem_repo2)}" + source "#{file_uri_for(gem_repo4)}" gem "sorbet", "0.5.6433" G error_message = <<~ERROR.strip - Could not find gem 'sorbet-static (= 0.5.6433) arm64-darwin-21', which is required by gem 'sorbet (= 0.5.6433)', in rubygems repository #{file_uri_for(gem_repo2)}/ or installed locally. + Could not find gem 'sorbet-static (= 0.5.6433)' with platform 'arm64-darwin-21', which is required by gem 'sorbet (= 0.5.6433)', in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally. The source contains the following gems matching 'sorbet-static (= 0.5.6433)': * sorbet-static-0.5.6433-universal-darwin-20 @@ -339,7 +339,7 @@ RSpec.describe "bundle install with specific platforms" do ERROR simulate_platform "arm64-darwin-21" do - bundle "install", :raise_on_error => false + bundle "lock", :raise_on_error => false end expect(err).to include(error_message).once @@ -347,12 +347,33 @@ RSpec.describe "bundle install with specific platforms" do # Make sure it doesn't print error twice in verbose mode simulate_platform "arm64-darwin-21" do - bundle "install --verbose", :raise_on_error => false + bundle "lock --verbose", :raise_on_error => false end expect(err).to include(error_message).once end + it "does not generate a lockfile if RUBY platform is forced and some gem has no RUBY variant available" do + build_repo4 do + build_gem("sorbet-static", "0.5.9889") {|s| s.platform = Gem::Platform.local } + end + + gemfile <<~G + source "#{file_uri_for(gem_repo4)}" + + gem "sorbet-static", "0.5.9889" + G + + bundle "lock", :raise_on_error => false, :env => { "BUNDLE_FORCE_RUBY_PLATFORM" => "true" } + + expect(err).to include <<~ERROR.rstrip + Could not find gem 'sorbet-static (= 0.5.9889)' with platform 'ruby' in rubygems repository #{file_uri_for(gem_repo4)}/ or installed locally. + + The source contains the following gems matching 'sorbet-static (= 0.5.9889)': + * sorbet-static-0.5.9889-#{Gem::Platform.local} + ERROR + end + private def setup_multiplatform_gem diff --git a/spec/bundler/install/gemfile_spec.rb b/spec/bundler/install/gemfile_spec.rb index 0f8f1ecfa8..e643573454 100644 --- a/spec/bundler/install/gemfile_spec.rb +++ b/spec/bundler/install/gemfile_spec.rb @@ -66,7 +66,7 @@ RSpec.describe "bundle install" do end end - context "with engine specified in symbol", :jruby do + context "with engine specified in symbol", :jruby_only do it "does not raise any error parsing Gemfile" do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" diff --git a/spec/bundler/install/gems/resolving_spec.rb b/spec/bundler/install/gems/resolving_spec.rb index f23d137bc1..b136dea8bd 100644 --- a/spec/bundler/install/gems/resolving_spec.rb +++ b/spec/bundler/install/gems/resolving_spec.rb @@ -187,11 +187,7 @@ RSpec.describe "bundle install with install-time dependencies" do bundle :install, :env => { "DEBUG_RESOLVER_TREE" => "1", "DEBUG" => "1" } - activated_groups = if local_platforms.any? - "net_b (1.0) (ruby), net_b (1.0) (#{local_platforms.join(", ")})" - else - "net_b (1.0) (ruby)" - end + activated_groups = "net_b (1.0) (ruby), net_b (1.0) (#{specific_local_platform})" expect(out).to include(" net_b"). and include("BUNDLER: Starting resolution"). diff --git a/spec/bundler/lock/lockfile_spec.rb b/spec/bundler/lock/lockfile_spec.rb index 8ec0a80bd0..ea9893fb0e 100644 --- a/spec/bundler/lock/lockfile_spec.rb +++ b/spec/bundler/lock/lockfile_spec.rb @@ -982,7 +982,7 @@ RSpec.describe "the lockfile format" do rack (1.0.0) PLATFORMS - #{lockfile_platforms_for(["java"] + local_platforms)} + #{lockfile_platforms_for(["java", specific_local_platform])} DEPENDENCIES rack diff --git a/spec/bundler/other/ext_spec.rb b/spec/bundler/other/ext_spec.rb index e13f62a856..9b829a2b36 100644 --- a/spec/bundler/other/ext_spec.rb +++ b/spec/bundler/other/ext_spec.rb @@ -44,6 +44,10 @@ RSpec.describe "Bundler::GemHelpers#generic" do expect(generic(pl("x64-mingw32"))).to eq(pl("x64-mingw32")) expect(generic(pl("x86_64-mingw32"))).to eq(pl("x64-mingw32")) end + + it "converts 64-bit mingw UCRT platform variants into x64-mingw-ucrt" do + expect(generic(pl("x64-mingw-ucrt"))).to eq(pl("x64-mingw-ucrt")) + end end RSpec.describe "Gem::SourceIndex#refresh!" do diff --git a/spec/bundler/other/platform_spec.rb b/spec/bundler/other/platform_spec.rb index bf38a05646..c157345cab 100644 --- a/spec/bundler/other/platform_spec.rb +++ b/spec/bundler/other/platform_spec.rb @@ -2,10 +2,6 @@ RSpec.describe "bundle platform" do context "without flags" do - let(:bundle_platform_platforms_string) do - local_platforms.reverse.map {|pl| "* #{pl}" }.join("\n") - end - it "returns all the output" do gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -20,7 +16,7 @@ RSpec.describe "bundle platform" do Your platform is: #{Gem::Platform.local} Your app has gems that work on these platforms: -#{bundle_platform_platforms_string} +* #{specific_local_platform} Your Gemfile specifies a Ruby version requirement: * ruby #{RUBY_VERSION} @@ -43,7 +39,7 @@ G Your platform is: #{Gem::Platform.local} Your app has gems that work on these platforms: -#{bundle_platform_platforms_string} +* #{specific_local_platform} Your Gemfile specifies a Ruby version requirement: * ruby #{RUBY_VERSION}p#{RUBY_PATCHLEVEL} @@ -64,7 +60,7 @@ G Your platform is: #{Gem::Platform.local} Your app has gems that work on these platforms: -#{bundle_platform_platforms_string} +* #{specific_local_platform} Your Gemfile does not specify a Ruby version requirement. G @@ -84,7 +80,7 @@ G Your platform is: #{Gem::Platform.local} Your app has gems that work on these platforms: -#{bundle_platform_platforms_string} +* #{specific_local_platform} Your Gemfile specifies a Ruby version requirement: * ruby #{not_local_ruby_version} @@ -305,7 +301,7 @@ G expect(bundled_app_lock).to exist end - it "installs fine with any engine", :jruby do + it "installs fine with any engine", :jruby_only do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -351,7 +347,7 @@ G should_be_engine_incorrect end - it "doesn't install when engine version doesn't match", :jruby do + it "doesn't install when engine version doesn't match", :jruby_only do install_gemfile <<-G, :raise_on_error => false source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -394,7 +390,7 @@ G expect(out).to match(/\AResolving dependencies\.\.\.\.*\nThe Gemfile's dependencies are satisfied\z/) end - it "checks fine with any engine", :jruby do + it "checks fine with any engine", :jruby_only do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -445,7 +441,7 @@ G should_be_engine_incorrect end - it "fails when engine version doesn't match", :jruby do + it "fails when engine version doesn't match", :jruby_only do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -511,7 +507,7 @@ G expect(the_bundle).to include_gems "rack 1.2", "rack-obama 1.0", "activesupport 3.0" end - it "updates fine with any engine", :jruby do + it "updates fine with any engine", :jruby_only do gemfile <<-G source "#{file_uri_for(gem_repo2)}" gem "activesupport" @@ -547,7 +543,7 @@ G should_be_ruby_version_incorrect end - it "fails when ruby engine doesn't match", :jruby do + it "fails when ruby engine doesn't match", :jruby_only do gemfile <<-G source "#{file_uri_for(gem_repo2)}" gem "activesupport" @@ -563,7 +559,7 @@ G should_be_engine_incorrect end - it "fails when ruby engine version doesn't match", :jruby do + it "fails when ruby engine version doesn't match", :jruby_only do gemfile <<-G source "#{file_uri_for(gem_repo2)}" gem "activesupport" @@ -615,7 +611,7 @@ G expect(out).to eq(default_bundle_path("gems", "rails-2.3.2").to_s) end - it "prints path if ruby version is correct for any engine", :jruby do + it "prints path if ruby version is correct for any engine", :jruby_only do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rails" @@ -651,7 +647,7 @@ G should_be_engine_incorrect end - it "fails if engine version doesn't match", :bundler => "< 3", :jruby => true do + it "fails if engine version doesn't match", :bundler => "< 3", :jruby_only => true do gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rails" @@ -699,7 +695,7 @@ G expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist end - it "copies the .gem file to vendor/cache when ruby version matches for any engine", :jruby do + it "copies the .gem file to vendor/cache when ruby version matches for any engine", :jruby_only do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem 'rack' @@ -735,7 +731,7 @@ G should_be_engine_incorrect end - it "fails if the engine version doesn't match", :jruby do + it "fails if the engine version doesn't match", :jruby_only do gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem 'rack' @@ -780,7 +776,7 @@ G expect(bundled_app("vendor/cache/rack-1.0.0.gem")).to exist end - it "copies the .gem file to vendor/cache when ruby version matches any engine", :jruby do + it "copies the .gem file to vendor/cache when ruby version matches any engine", :jruby_only do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem 'rack' @@ -816,7 +812,7 @@ G should_be_engine_incorrect end - it "fails if the engine version doesn't match", :jruby do + it "fails if the engine version doesn't match", :jruby_only do gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem 'rack' @@ -859,7 +855,7 @@ G expect(out).to include("0.9.1") end - it "activates the correct gem when ruby version matches any engine", :jruby do + it "activates the correct gem when ruby version matches any engine", :jruby_only do system_gems "rack-1.0.0", "rack-0.9.1", :path => default_bundle_path gemfile <<-G source "#{file_uri_for(gem_repo1)}" @@ -896,7 +892,7 @@ G should_be_engine_incorrect end - # it "fails when the engine version doesn't match", :jruby do + # it "fails when the engine version doesn't match", :jruby_only do # gemfile <<-G # gem "rack", "0.9.1" # @@ -947,7 +943,7 @@ G expect(out).to include("0.9.1") end - it "starts IRB with the default group loaded when ruby version matches", :readline, :jruby do + it "starts IRB with the default group loaded when ruby version matches", :readline, :jruby_only do gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -992,7 +988,7 @@ G should_be_engine_incorrect end - it "fails when engine version doesn't match", :jruby do + it "fails when engine version doesn't match", :jruby_only do gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "rack" @@ -1047,7 +1043,7 @@ G expect(bundled_app_lock).to exist end - it "makes a Gemfile.lock if setup succeeds for any engine", :jruby do + it "makes a Gemfile.lock if setup succeeds for any engine", :jruby_only do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "yard" @@ -1096,7 +1092,7 @@ G should_be_engine_incorrect end - it "fails when engine version doesn't match", :jruby do + it "fails when engine version doesn't match", :jruby_only do install_gemfile <<-G, :raise_on_error => false source "#{file_uri_for(gem_repo1)}" gem "yard" @@ -1169,7 +1165,7 @@ G expect(out).to match(Regexp.new(expected_output)) end - it "returns list of outdated gems when the ruby version matches for any engine", :jruby do + it "returns list of outdated gems when the ruby version matches for any engine", :jruby_only do bundle :install update_repo2 do build_gem "activesupport", "3.0" @@ -1231,7 +1227,7 @@ G should_be_engine_incorrect end - it "fails when the engine version doesn't match", :jruby do + it "fails when the engine version doesn't match", :jruby_only do update_repo2 do build_gem "activesupport", "3.0" update_git "foo", :path => lib_path("foo") @@ -1249,7 +1245,7 @@ G should_be_engine_version_incorrect end - it "fails when the patchlevel doesn't match", :jruby do + it "fails when the patchlevel doesn't match", :jruby_only do update_repo2 do build_gem "activesupport", "3.0" update_git "foo", :path => lib_path("foo") @@ -1267,7 +1263,7 @@ G should_be_patchlevel_incorrect end - it "fails when the patchlevel is a fixnum", :jruby do + it "fails when the patchlevel is a fixnum", :jruby_only do update_repo2 do build_gem "activesupport", "3.0" update_git "foo", :path => lib_path("foo") diff --git a/spec/bundler/resolver/platform_spec.rb b/spec/bundler/resolver/platform_spec.rb index bc4081f8b5..8eaed4220a 100644 --- a/spec/bundler/resolver/platform_spec.rb +++ b/spec/bundler/resolver/platform_spec.rb @@ -291,7 +291,7 @@ RSpec.describe "Resolving platform craziness" do describe "with mingw32" do before :each do @index = build_index do - platforms "mingw32 mswin32 x64-mingw32" do |platform| + platforms "mingw32 mswin32 x64-mingw32 x64-mingw-ucrt" do |platform| gem "thin", "1.2.7", platform end gem "win32-api", "1.5.1", "universal-mingw32" @@ -312,7 +312,7 @@ RSpec.describe "Resolving platform craziness" do should_resolve_as %w[thin-1.2.7-mingw32] end - it "finds x64-mingw gems" do + it "finds x64-mingw32 gems" do platforms "x64-mingw32" dep "thin" should_resolve_as %w[thin-1.2.7-x64-mingw32] @@ -329,6 +329,22 @@ RSpec.describe "Resolving platform craziness" do dep "win32-api" should_resolve_as %w[win32-api-1.5.1-universal-mingw32] end + + if Gem.rubygems_version >= Gem::Version.new("3.2.28") + it "finds x64-mingw-ucrt gems" do + platforms "x64-mingw-ucrt" + dep "thin" + should_resolve_as %w[thin-1.2.7-x64-mingw-ucrt] + end + end + + if Gem.rubygems_version >= Gem::Version.new("3.3.18") + it "finds universal-mingw gems on x64-mingw-ucrt" do + platform "x64-mingw-ucrt" + dep "win32-api" + should_resolve_as %w[win32-api-1.5.1-universal-mingw32] + end + end end describe "with conflicting cases" do diff --git a/spec/bundler/runtime/platform_spec.rb b/spec/bundler/runtime/platform_spec.rb index f7159635e6..34dc5ba799 100644 --- a/spec/bundler/runtime/platform_spec.rb +++ b/spec/bundler/runtime/platform_spec.rb @@ -86,7 +86,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do racc (1.5.2) PLATFORMS - #{lockfile_platforms_for(["ruby"] + local_platforms)} + #{lockfile_platforms_for(["ruby", specific_local_platform])} DEPENDENCIES nokogiri (~> 1.11) @@ -145,7 +145,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do expect(the_bundle).not_to include_gems "nokogiri 1.11.1 #{Bundler.local_platform}" end - it "will use the java platform if both generic java and generic ruby platforms are locked", :jruby do + it "will use the java platform if both generic java and generic ruby platforms are locked", :jruby_only do gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "nokogiri" @@ -204,7 +204,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do expect(the_bundle).to include_gems "nokogiri 1.4.2", "platform_specific 1.0 x86-darwin-100" end - it "allows specifying only-ruby-platform on jruby", :jruby do + it "allows specifying only-ruby-platform on jruby", :jruby_only do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "nokogiri" @@ -246,7 +246,7 @@ RSpec.describe "Bundler.setup with multi platform stuff" do expect(the_bundle).to include_gems "nokogiri 1.4.2", "platform_specific 1.0 RUBY" end - it "doesn't pull platform specific gems on truffleruby", :truffleruby do + it "doesn't pull platform specific gems on truffleruby", :truffleruby_only do install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" gem "platform_specific" @@ -255,6 +255,66 @@ RSpec.describe "Bundler.setup with multi platform stuff" do expect(the_bundle).to include_gems "platform_specific 1.0 RUBY" end + it "doesn't pull platform specific gems on truffleruby (except when whitelisted) even if lockfile was generated with an older version that declared RUBY as platform", :truffleruby_only do + gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + gem "platform_specific" + G + + lockfile <<-L + GEM + remote: #{file_uri_for(gem_repo1)}/ + specs: + platform_specific (1.0) + + PLATFORMS + ruby + + DEPENDENCIES + platform_specific + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle "install" + + expect(the_bundle).to include_gems "platform_specific 1.0 RUBY" + + build_repo4 do + build_gem "libv8" + + build_gem "libv8" do |s| + s.platform = Bundler.local_platform + end + end + + gemfile <<-G + source "#{file_uri_for(gem_repo4)}" + gem "libv8" + G + + lockfile <<-L + GEM + remote: #{file_uri_for(gem_repo4)}/ + specs: + libv8 (1.0) + + PLATFORMS + ruby + + DEPENDENCIES + libv8 + + BUNDLED WITH + #{Bundler::VERSION} + L + + bundle "install" + + expect(the_bundle).to include_gems "libv8 1.0 #{Bundler.local_platform}" + end + it "allows specifying only-ruby-platform on windows with dependency platforms" do simulate_windows do install_gemfile <<-G diff --git a/spec/bundler/runtime/require_spec.rb b/spec/bundler/runtime/require_spec.rb index d91b5f8666..e59fa564f6 100644 --- a/spec/bundler/runtime/require_spec.rb +++ b/spec/bundler/runtime/require_spec.rb @@ -449,8 +449,6 @@ RSpec.describe "Bundler.require with platform specific dependencies" do end it "requires gems pinned to multiple platforms, including the current one" do - skip "platform issues" if Gem.win_platform? - install_gemfile <<-G source "#{file_uri_for(gem_repo1)}" diff --git a/spec/bundler/runtime/setup_spec.rb b/spec/bundler/runtime/setup_spec.rb index 582ba7ba93..fecf4cd98b 100644 --- a/spec/bundler/runtime/setup_spec.rb +++ b/spec/bundler/runtime/setup_spec.rb @@ -637,6 +637,22 @@ RSpec.describe "Bundler.setup" do expect(err).to be_empty end + it "doesn't re-resolve when deleting dependencies" do + install_gemfile <<-G + source "#{file_uri_for(gem_repo1)}" + gem "rack" + gem "actionpack" + G + + install_gemfile <<-G, :verbose => true + source "#{file_uri_for(gem_repo1)}" + gem "rack" + G + + expect(out).to include("Some dependencies were deleted, using a subset of the resolution from the lockfile") + expect(err).to be_empty + end + it "remembers --without and does not include groups passed to Bundler.setup" do bundle "config set --local without rails" install_gemfile <<-G diff --git a/spec/bundler/support/builders.rb b/spec/bundler/support/builders.rb index 4d203f6e21..285b68c047 100644 --- a/spec/bundler/support/builders.rb +++ b/spec/bundler/support/builders.rb @@ -122,6 +122,10 @@ module Spec end build_gem "platform_specific" do |s| + s.platform = "x64-mingw-ucrt" + end + + build_gem "platform_specific" do |s| s.platform = "x86-darwin-100" s.write "lib/platform_specific.rb", "PLATFORM_SPECIFIC = '1.0.0 x86-darwin-100'" end diff --git a/spec/bundler/support/filters.rb b/spec/bundler/support/filters.rb index 96f2e2a274..c3b7a425ae 100644 --- a/spec/bundler/support/filters.rb +++ b/spec/bundler/support/filters.rb @@ -33,8 +33,8 @@ RSpec.configure do |config| config.filter_run_excluding :no_color_tty => Gem.win_platform? || !ENV["GITHUB_ACTION"].nil? config.filter_run_excluding :permissions => Gem.win_platform? config.filter_run_excluding :readline => Gem.win_platform? - config.filter_run_excluding :jruby => RUBY_ENGINE != "jruby" - config.filter_run_excluding :truffleruby => RUBY_ENGINE != "truffleruby" + config.filter_run_excluding :jruby_only => RUBY_ENGINE != "jruby" + config.filter_run_excluding :truffleruby_only => RUBY_ENGINE != "truffleruby" config.filter_run_excluding :man => Gem.win_platform? config.filter_run_when_matching :focus unless ENV["CI"] diff --git a/spec/bundler/support/platforms.rb b/spec/bundler/support/platforms.rb index 07973fd727..48479723e4 100644 --- a/spec/bundler/support/platforms.rb +++ b/spec/bundler/support/platforms.rb @@ -55,13 +55,15 @@ module Spec def local_tag if RUBY_PLATFORM == "java" :jruby + elsif ["x64-mingw32", "x64-mingw-ucrt"].include?(RUBY_PLATFORM) + :x64_mingw else :ruby end end def not_local_tag - [:ruby, :jruby].find {|tag| tag != local_tag } + [:jruby, :x64_mingw, :ruby].find {|tag| tag != local_tag } end def local_ruby_engine @@ -74,7 +76,7 @@ module Spec def not_local_engine_version case not_local_tag - when :ruby + when :ruby, :x64_mingw not_local_ruby_version when :jruby "1.6.1" @@ -90,15 +92,11 @@ module Spec end def lockfile_platforms - lockfile_platforms_for(local_platforms) + lockfile_platforms_for([specific_local_platform]) end def lockfile_platforms_for(platforms) platforms.map(&:to_s).sort.join("\n ") end - - def local_platforms - [specific_local_platform] - end end end diff --git a/spec/bundler/support/rubygems_ext.rb b/spec/bundler/support/rubygems_ext.rb index eb7e321080..4553c0606e 100644 --- a/spec/bundler/support/rubygems_ext.rb +++ b/spec/bundler/support/rubygems_ext.rb @@ -137,8 +137,8 @@ module Spec ENV["BUNDLE_PATH__SYSTEM"] = "true" end - output = `#{Gem.ruby} #{File.expand_path("support/bundle.rb", Path.spec_dir)} install --verbose` - raise "Error when installing gems in #{gemfile}: #{output}" unless $?.success? + puts `#{Gem.ruby} #{File.expand_path("support/bundle.rb", Path.spec_dir)} install --verbose` + raise unless $?.success? ensure if path ENV["BUNDLE_PATH"] = old_path |