Update .init! to attempt repair if instructed
This commit is contained in:
parent
d5c5561302
commit
3fb5913af1
|
@ -31,7 +31,7 @@ module Vagrant
|
||||||
|
|
||||||
# Initializes Bundler and the various gem paths so that we can begin
|
# Initializes Bundler and the various gem paths so that we can begin
|
||||||
# loading gems. This must only be called once.
|
# loading gems. This must only be called once.
|
||||||
def init!(plugins)
|
def init!(plugins, repair=false)
|
||||||
# Add HashiCorp RubyGems source
|
# Add HashiCorp RubyGems source
|
||||||
Gem.sources << HASHICORP_GEMSTORE
|
Gem.sources << HASHICORP_GEMSTORE
|
||||||
|
|
||||||
|
@ -48,7 +48,8 @@ module Vagrant
|
||||||
# Sets that we can resolve our dependencies from
|
# Sets that we can resolve our dependencies from
|
||||||
current_set = Gem::Resolver::CurrentSet.new
|
current_set = Gem::Resolver::CurrentSet.new
|
||||||
plugin_set = Gem::Resolver::VendorSet.new
|
plugin_set = Gem::Resolver::VendorSet.new
|
||||||
|
repair_result = nil
|
||||||
|
begin
|
||||||
# Register all known plugin specifications to the plugin set
|
# Register all known plugin specifications to the plugin set
|
||||||
Dir.glob(plugin_gem_path.join('specifications/*.gemspec').to_s).each do |spec_path|
|
Dir.glob(plugin_gem_path.join('specifications/*.gemspec').to_s).each do |spec_path|
|
||||||
spec = Gem::Specification.load(spec_path)
|
spec = Gem::Specification.load(spec_path)
|
||||||
|
@ -66,6 +67,23 @@ module Vagrant
|
||||||
|
|
||||||
# Resolve the request set to ensure proper activation order
|
# Resolve the request set to ensure proper activation order
|
||||||
solution = request_set.resolve(composed_set)
|
solution = request_set.resolve(composed_set)
|
||||||
|
rescue Gem::UnsatisfiableDependencyError => failure
|
||||||
|
if repair
|
||||||
|
raise failure if @init_retried
|
||||||
|
install(plugins)
|
||||||
|
@init_retried = true
|
||||||
|
retry
|
||||||
|
else
|
||||||
|
$stderr.puts "Vagrant failed to properly initialize due to an error while"
|
||||||
|
$stderr.puts "while attempting to load configured plugins. This can be caused"
|
||||||
|
$stderr.puts "by manually tampering with the 'plugins.json' file, or by a"
|
||||||
|
$stderr.puts "recent Vagrant upgrade. To fix this problem, please run:\n\n"
|
||||||
|
$stderr.puts " vagrant plugin repair\n\n"
|
||||||
|
$stderr.puts "The error message is shown below:\n\n"
|
||||||
|
$stderr.puts failure.message
|
||||||
|
exit 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Activate the gems
|
# Activate the gems
|
||||||
begin
|
begin
|
||||||
|
|
Loading…
Reference in New Issue