[前][次][番号順一覧][スレッド一覧]

ruby-changes:74450

From: Hiroshi <ko1@a...>
Date: Fri, 11 Nov 2022 17:24:30 +0900 (JST)
Subject: [ruby-changes:74450] 28611be6ee (master): Merge RubyGems/Bundler master from ee2f8398324af4bc1b95f7565ce2fda98126e026

https://git.ruby-lang.org/ruby.git/commit/?id=28611be6ee

From 28611be6ee84ba8eb19e667a70ae129833b98b8b Mon Sep 17 00:00:00 2001
From: Hiroshi SHIBATA <hsbt@r...>
Date: Fri, 11 Nov 2022 15:05:59 +0900
Subject: Merge RubyGems/Bundler master from
 ee2f8398324af4bc1b95f7565ce2fda98126e026

---
 lib/bundler/definition.rb                          |  2 +-
 lib/bundler/lazy_specification.rb                  |  4 +--
 lib/rubygems/ext/cargo_builder.rb                  |  4 +++
 spec/bundler/commands/update_spec.rb               |  6 ++++
 .../install/gemfile/specific_platform_spec.rb      | 32 ++++++++++++++++++++++
 .../artifice/compact_index_precompiled_before.rb   | 25 +++++++++++++++++
 .../custom_name/Cargo.lock                         |  8 +++---
 .../custom_name/Cargo.toml                         |  2 +-
 .../rust_ruby_example/Cargo.lock                   |  8 +++---
 .../rust_ruby_example/Cargo.toml                   |  2 +-
 10 files changed, 79 insertions(+), 14 deletions(-)
 create mode 100644 spec/bundler/support/artifice/compact_index_precompiled_before.rb

diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb
index 95be7a7e27..3836841f3f 100644
--- a/lib/bundler/definition.rb
+++ b/lib/bundler/definition.rb
@@ -357,7 +357,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/definition.rb#L357
           "bundle config unset deployment"
         end
         msg << "\n\nIf this is a development machine, remove the #{Bundler.default_gemfile} " \
-               "freeze \nby running `#{suggested_command}`."
+               "freeze \nby running `#{suggested_command}`." if suggested_command
       end
 
       added =   []
diff --git a/lib/bundler/lazy_specification.rb b/lib/bundler/lazy_specification.rb
index f5fe2e64ae..949e8264ba 100644
--- a/lib/bundler/lazy_specification.rb
+++ b/lib/bundler/lazy_specification.rb
@@ -79,9 +79,7 @@ module Bundler https://github.com/ruby/ruby/blob/trunk/lib/bundler/lazy_specification.rb#L79
       candidates = if source.is_a?(Source::Path) || !ruby_platform_materializes_to_ruby_platform?
         target_platform = ruby_platform_materializes_to_ruby_platform? ? platform : local_platform
 
-        source.specs.search(Dependency.new(name, version)).select do |spec|
-          MatchPlatform.platforms_match?(spec.platform, target_platform)
-        end
+        GemHelpers.select_best_platform_match(source.specs.search(Dependency.new(name, version)), target_platform)
       else
         source.specs.search(self)
       end
diff --git a/lib/rubygems/ext/cargo_builder.rb b/lib/rubygems/ext/cargo_builder.rb
index e33b07a8a2..24c1d3ae6e 100644
--- a/lib/rubygems/ext/cargo_builder.rb
+++ b/lib/rubygems/ext/cargo_builder.rb
@@ -37,6 +37,7 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/cargo_builder.rb#L37
   def build_env
     build_env = rb_config_env
     build_env["RUBY_STATIC"] = "true" if ruby_static? && ENV.key?("RUBY_STATIC")
+    build_env["RUSTFLAGS"] = "#{ENV["RUSTFLAGS"]} --cfg=rb_sys_gem".strip
     build_env
   end
 
@@ -92,6 +93,9 @@ class Gem::Ext::CargoBuilder < Gem::Ext::Builder https://github.com/ruby/ruby/blob/trunk/lib/rubygems/ext/cargo_builder.rb#L93
       # run on one that isn't the missing libraries will cause the extension
       # to fail on start.
       flags += ["-C", "link-arg=-static-libgcc"]
+    elsif darwin_target?
+      # Ventura does not always have this flag enabled
+      flags += ["-C", "link-arg=-Wl,-undefined,dynamic_lookup"]
     end
 
     flags
diff --git a/spec/bundler/commands/update_spec.rb b/spec/bundler/commands/update_spec.rb
index 11ff49bf89..1ad5f76466 100644
--- a/spec/bundler/commands/update_spec.rb
+++ b/spec/bundler/commands/update_spec.rb
@@ -613,6 +613,12 @@ RSpec.describe "bundle update" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/commands/update_spec.rb#L613
       expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m).
         and match(/freeze \nby running `bundle config unset deployment`./m)
     end
+
+    it "should not suggest any command to unfreeze bundler if frozen is set through ENV" do
+      bundle "update", :all => true, :raise_on_error => false, :env => { "BUNDLE_FROZEN" => "true" }
+      expect(err).to match(/You are trying to install in deployment mode after changing.your Gemfile/m)
+      expect(err).not_to match(/by running/)
+    end
   end
 
   describe "with --source option" do
diff --git a/spec/bundler/install/gemfile/specific_platform_spec.rb b/spec/bundler/install/gemfile/specific_platform_spec.rb
index 699672f357..98efec396c 100644
--- a/spec/bundler/install/gemfile/specific_platform_spec.rb
+++ b/spec/bundler/install/gemfile/specific_platform_spec.rb
@@ -148,6 +148,38 @@ RSpec.describe "bundle install with specific platforms" do https://github.com/ruby/ruby/blob/trunk/spec/bundler/install/gemfile/specific_platform_spec.rb#L148
       expect(out).to include("Using libv8 8.4.255.0 (universal-darwin)")
     end
 
+    it "chooses platform specific gems even when resolving upon materialization and the API returns more specific plaforms first" do
+      build_repo4 do
+        build_gem("grpc", "1.50.0")
+        build_gem("grpc", "1.50.0") {|s| s.platform = "universal-darwin" }
+      end
+
+      gemfile <<-G
+        source "https://localgemserver.test"
+        gem "grpc"
+      G
+
+      # simulate lockfile created with old bundler, which only locks for ruby platform
+      lockfile <<-L
+        GEM
+          remote: https://localgemserver.test/
+          specs:
+            grpc (1.50.0)
+
+        PLATFORMS
+          ruby
+
+        DEPENDENCIES
+          grpc
+
+        BUNDLED WITH
+           #{Bundler::VERSION}
+      L
+
+      bundle "install --verbose", :artifice => "compact_index_precompiled_before", :env => { "BUNDLER_SPEC_GEM_REPO" => gem_repo4.to_s }
+      expect(out).to include("Installing grpc 1.50.0 (universal-darwin)")
+    end
+
     it "caches the universal-darwin gem when --all-platforms is passed and properly picks it up on further bundler invocations" do
       setup_multiplatform_gem
       gemfile(google_protobuf)
diff --git a/spec/bundler/support/artifice/compact_index_precompiled_before.rb b/spec/bundler/support/artifice/compact_index_precompiled_before.rb
new file mode 100644
index 0000000000..9f310e653b
--- /dev/null
+++ b/spec/bundler/support/artifice/compact_index_precompiled_before.rb
@@ -0,0 +1,25 @@ https://github.com/ruby/ruby/blob/trunk/spec/bundler/support/artifice/compact_index_precompiled_before.rb#L1
+# frozen_string_literal: true
+
+require_relative "compact_index"
+
+Artifice.deactivate
+
+class CompactIndexPrecompiledBefore < CompactIndexAPI
+  get "/info/:name" do
+    etag_response do
+      gem = gems.find {|g| g.name == params[:name] }
+      move_ruby_variant_to_the_end(CompactIndex.info(gem ? gem.versions : []))
+    end
+  end
+
+  private
+
+  def move_ruby_variant_to_the_end(response)
+    lines = response.split("\n")
+    ruby = lines.find {|line| /\A\d+\.\d+\.\d* \|/.match(line) }
+    lines.delete(ruby)
+    lines.push(ruby).join("\n")
+  end
+end
+
+Artifice.activate_with(CompactIndexPrecompiledBefore)
diff --git a/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock b/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock
index aa975b1cd0..08c97618fd 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock
+++ b/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock
@@ -160,18 +160,18 @@ dependencies = [ https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.lock#L160
 
 [[package]]
 name = "rb-sys"
-version = "0.9.35"
+version = "0.9.37"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2d2bde30824a18f2e68cd1c8004cec16656764c6efc385bc1c7fb4c904b276a5"
+checksum = "5ba942b6777ea18ded013b267023a9c98994557e6539e43740de9e75084cb124"
 dependencies = [
  "rb-sys-build",
 ]
 
 [[package]]
 name = "rb-sys-build"
-version = "0.9.35"
+version = "0.9.37"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ff5d3ba92624df9c66bf0d1f0251d96284f08ac9773b7723d370e3f225c1d38"
+checksum = "d35109e1a11ef8d1a988db242ab2ba2e80170f9f5a28f88ab30184a2cea8e09b"
 dependencies = [
  "bindgen",
  "linkify",
diff --git a/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml b/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml
index 6673f78464..8175b5ae2e 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml
+++ b/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml
@@ -7,4 +7,4 @@ edition = "2021" https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_ext_cargo_builder/custom_name/Cargo.toml#L7
 crate-type = ["cdylib"]
 
 [dependencies]
-rb-sys = { version = "0.9.35", features = ["gem"] }
+rb-sys = "0.9.37"
diff --git a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock
index e7e91de576..eb71f25570 100644
--- a/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock
+++ b/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock
@@ -153,18 +153,18 @@ dependencies = [ https://github.com/ruby/ruby/blob/trunk/test/rubygems/test_gem_ext_cargo_builder/rust_ruby_example/Cargo.lock#L153
 
 [[package]]
 name = "rb-sys"
-version = "0.9.35"
+version = "0.9.37"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "2d2bde30824a18f2e68cd1c8004cec16656764c6efc385bc1c7fb4c904b276a5"
+checksum = "5ba942b6777ea18ded013b267023a9c98994557e6539e43740de9e75084cb124"
 dependencies = [
  "rb-sys-build",
 ]
 
 [[package]]
 name = "rb-sys-build"
-version = "0.9.35"
+version = "0.9.37"
 source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "5ff5d3ba92624df9c66bf0d1f0251d96284f08ac9773b7723d370e3f225c1d38"
+checksum (... truncated)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]