From ce35611c34fdbf7783b65f1483c1c9147439bafb Mon Sep 17 00:00:00 2001 From: Chris Roberts Date: Thu, 1 Dec 2016 08:15:04 -0800 Subject: [PATCH] Detect load failure within solution set and retry if found Installation solution sets in 2.2.5 can end up out of order (not seen in 2.3.1) causing LoadErrors when the specification is in the solution set during validation. This detects the missing spec within the solution and if found will move spec to the start of the solution set and retry solution activation. --- lib/vagrant/bundler.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/lib/vagrant/bundler.rb b/lib/vagrant/bundler.rb index 3103382a7..aa48dc1f9 100644 --- a/lib/vagrant/bundler.rb +++ b/lib/vagrant/bundler.rb @@ -330,6 +330,20 @@ module Vagrant # again, just reverse order on failure and attempt again. if retried @logger.error("Failed to load solution set - #{e.class}: #{e}") + matcher = e.message.match(/Could not find '(?[^']+)'/) + if matcher && !matcher["gem_name"].empty? + desired_activation_request = solution.detect do |request| + request.name == matcher["gem_name"] + end + if desired_activation_request && !desired_activation_request.full_spec.activated? + activation_request = desired_activation_request + @logger.warn("Found misordered activation request for #{desired_activation_request.full_name}. Moving to solution HEAD.") + solution.delete(desired_activation_request) + solution.unshift(desired_activation_request) + retry + end + end + raise else @logger.debug("Failed to load solution set. Retrying with reverse order.")