[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
This commit is contained in:
Han Young 2023-11-01 11:58:31 +08:00 committed by git
parent 7efe0669ae
commit b4bf8c9ee2
2 changed files with 12 additions and 1 deletions

View File

@ -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\.(?<arch>.*?)-/ =~ (CROSS_COMPILING || RUBY_PLATFORM)
local_platform = Platform.local
if local_platform.cpu == "universal"

View File

@ -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)