diff --git a/tool/rbinstall.rb b/tool/rbinstall.rb index 85b4fb4555..7c482a2c20 100755 --- a/tool/rbinstall.rb +++ b/tool/rbinstall.rb @@ -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