From b4bf8c9ee2d716adf5fc08e67c4b26d6a8f929c2 Mon Sep 17 00:00:00 2001 From: Han Young Date: Wed, 1 Nov 2023 11:58:31 +0800 Subject: [PATCH] [rubygems/rubygems] Ensure we are using the same extension dir Since #6945 the extension dir changed to Gem::BasicSpecification's implementation, we didn't hook that in rubygems_ext.rb. So for universal rubies, we ended up using the universal platform name when installing, but arch replaced platform name when checking. This lead to native extensions can never be correctly installed on universal rubies. Hook Gem::BasicSpecifications so the behavior is consistent on installing and checking. https://github.com/rubygems/rubygems/commit/8d699ed096 --- lib/bundler/rubygems_ext.rb | 2 +- spec/bundler/bundler/stub_specification_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/bundler/rubygems_ext.rb b/lib/bundler/rubygems_ext.rb index dadac408b7..0296fc543d 100644 --- a/lib/bundler/rubygems_ext.rb +++ b/lib/bundler/rubygems_ext.rb @@ -338,7 +338,7 @@ module Gem end # On universal Rubies, resolve the "universal" arch to the real CPU arch, without changing the extension directory. - class Specification + class BasicSpecification if /^universal\.(?.*?)-/ =~ (CROSS_COMPILING || RUBY_PLATFORM) local_platform = Platform.local if local_platform.cpu == "universal" diff --git a/spec/bundler/bundler/stub_specification_spec.rb b/spec/bundler/bundler/stub_specification_spec.rb index fb612813c2..dae9f3cfba 100644 --- a/spec/bundler/bundler/stub_specification_spec.rb +++ b/spec/bundler/bundler/stub_specification_spec.rb @@ -19,6 +19,17 @@ RSpec.describe Bundler::StubSpecification do end end + describe "#gem_build_complete_path" do + it "StubSpecification should have equal gem_build_complete_path as Specification" do + spec_path = File.join(File.dirname(__FILE__), "specifications", "foo.gemspec") + spec = Gem::Specification.load(spec_path) + gem_stub = Gem::StubSpecification.new(spec_path, File.dirname(__FILE__),"","") + + stub = described_class.from_stub(gem_stub) + expect(stub.gem_build_complete_path).to eq spec.gem_build_complete_path + end + end + describe "#manually_installed?" do it "returns true if installed_by_version is nil or 0" do stub = described_class.from_stub(with_bundler_stub_spec)