Simplified to find gemspecs for bundled gems (#12709)

* Simplified to find gemspecs for bundled gems

Co-authored-by: Nobuyoshi Nakada <nobu.nakada@gmail.com>
This commit is contained in:
Hiroshi SHIBATA 2025-02-07 18:40:07 +09:00 committed by GitHub
parent 8dbbc79e8b
commit 7178593558
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
Notes: git 2025-02-07 09:40:26 +00:00
Merged-By: hsbt <hsbt@ruby-lang.org>

View File

@ -1138,21 +1138,18 @@ install?(:ext, :comm, :gem, :'bundled-gems') do
next unless /^(\S+)\s+(\S+).*/ =~ name
gem = $1
gem_name = "#$1-#$2"
# Try to find the original gemspec file
path = "#{srcdir}/.bundle/gems/#{gem_name}/#{gem}.gemspec"
unless File.exist?(path)
# Try to find the gemspec file for C ext gems
path = [
# gemspec that removed duplicated dependencies of bundled gems
"#{srcdir}/.bundle/gems/#{gem_name}/#{gem}.gemspec",
# gemspec for C ext gems, It has the original dependencies
# ex .bundle/gems/debug-1.7.1/debug-1.7.1.gemspec
# This gemspec keep the original dependencies
path = "#{srcdir}/.bundle/gems/#{gem_name}/#{gem_name}.gemspec"
unless File.exist?(path)
# Try to find the gemspec file for gems that hasn't own gemspec
path = "#{srcdir}/.bundle/specifications/#{gem_name}.gemspec"
unless File.exist?(path)
skipped[gem_name] = "gemspec not found"
next
end
end
"#{srcdir}/.bundle/gems/#{gem_name}/#{gem_name}.gemspec",
# original gemspec generated by rubygems
"#{srcdir}/.bundle/specifications/#{gem_name}.gemspec"
].find { |gemspec| File.exist?(gemspec) }
if path.nil?
skipped[gem_name] = "gemspec not found"
next
end
spec = load_gemspec(path, "#{srcdir}/.bundle/gems/#{gem_name}")
unless spec.platform == Gem::Platform::RUBY