[rubygems/rubygems] Fix Gem::Specification#gem_dir losing custom source for some reason

https://github.com/rubygems/rubygems/commit/f8f589b1b8
This commit is contained in:
David Rodríguez 2024-10-07 17:31:42 +02:00 committed by git
parent 83456d1e9a
commit 73834f11fa
3 changed files with 22 additions and 8 deletions

View File

@ -123,6 +123,13 @@ module Gem
end
end
# Can be removed once RubyGems 3.5.21 support is dropped
remove_method :gem_dir if method_defined?(:gem_dir, false)
def gem_dir
full_gem_path
end
unless const_defined?(:LATEST_RUBY_WITHOUT_PATCH_VERSIONS)
LATEST_RUBY_WITHOUT_PATCH_VERSIONS = Gem::Version.new("2.1")

View File

@ -1912,14 +1912,6 @@ class Gem::Specification < Gem::BasicSpecification
@full_name ||= super
end
##
# Work around old bundler versions removing my methods
# Can be removed once RubyGems can no longer install Bundler 2.5
def gem_dir # :nodoc:
super
end
def gems_dir
@gems_dir ||= File.join(base_dir, "gems")
end

View File

@ -706,6 +706,21 @@ RSpec.describe "Bundler.setup" do
expect(out).to be_empty
end
it "has gem_dir pointing to local repo" do
build_lib "foo", "1.0", path: bundled_app
install_gemfile <<-G
source "https://gem.repo1"
gemspec
G
run <<-R
puts Gem.loaded_specs['foo'].gem_dir
R
expect(out).to eq(bundled_app.to_s)
end
it "does not load all gemspecs" do
install_gemfile <<-G
source "https://gem.repo1"