From 261f5d3202683125651a12519c079ef9d5f303f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?David=20Rodr=C3=ADguez?= Date: Tue, 5 Nov 2024 19:20:55 +0100 Subject: [PATCH] [rubygems/rubygems] Add naive infinite loop detection when fixing lockfile dependencies https://github.com/rubygems/rubygems/commit/5e933968a2 --- lib/bundler/definition.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/bundler/definition.rb b/lib/bundler/definition.rb index 5d26da7753..9ce38209d6 100644 --- a/lib/bundler/definition.rb +++ b/lib/bundler/definition.rb @@ -587,10 +587,18 @@ module Bundler end def materialize(dependencies) + # Tracks potential endless loops trying to re-resolve. + # TODO: Remove as dead code if not reports are received in a while + incorrect_spec = nil + specs = begin resolve.materialize(dependencies) rescue IncorrectLockfileDependencies => e - reresolve_without([e.spec]) + spec = e.spec + raise "Infinite loop while fixing lockfile dependencies" if incorrect_spec == spec + + incorrect_spec = spec + reresolve_without([spec]) retry end