diff --git a/lib/vagrant.rb b/lib/vagrant.rb index e96c9b19d..683137e8d 100644 --- a/lib/vagrant.rb +++ b/lib/vagrant.rb @@ -254,23 +254,9 @@ end if Vagrant.plugins_init? begin Vagrant::Bundler.instance.init!(plugins) - rescue Gem::ConflictError, Gem::DependencyError => e - $stderr.puts "Vagrant experienced a version conflict with some installed plugins!" - $stderr.puts "This usually happens if you recently upgraded Vagrant. As part of the" - $stderr.puts "upgrade process, some existing plugins are no longer compatible with" - $stderr.puts "this version of Vagrant. The recommended way to fix this is to remove" - $stderr.puts "your existing plugins and reinstall them one-by-one. To remove all" - $stderr.puts "plugins:" - $stderr.puts "" - $stderr.puts " vagrant expunge" - $stderr.puts "" - $stderr.puts "Note if you have an alternate VAGRANT_HOME environmental variable" - $stderr.puts "set, the folders above will be in that directory rather than your" - $stderr.puts "user's home directory." - $stderr.puts "" - $stderr.puts "The error message is shown below:\n\n" - $stderr.puts e.message - exit 1 + rescue Exception => e + global_logger.error("Plugin initialization error - #{e.class}: #{e}") + raise Vagrant::Errors::PluginInitError, message: e.to_s end end diff --git a/lib/vagrant/bundler.rb b/lib/vagrant/bundler.rb index ba4cfef54..284152890 100644 --- a/lib/vagrant/bundler.rb +++ b/lib/vagrant/bundler.rb @@ -92,11 +92,10 @@ module Vagrant end end - @logger.debug("Initialization solution set: #{solution.map(&:full_name)}") - # Activate the gems + retried = false begin - retried = false + @logger.debug("Initialization solution set: #{solution.map(&:full_name)}") solution.each do |activation_request| unless activation_request.full_spec.activated? @logger.debug("Activating gem #{activation_request.full_spec.full_name}") @@ -107,14 +106,16 @@ module Vagrant end end end - rescue Gem::LoadError + rescue Gem::LoadError => e # Depending on the version of Ruby, the ordering of the solution set # will be either 0..n (molinillo) or n..0 (pre-molinillo). Instead of # attempting to determine what's in use, or if it has some how changed # again, just reverse order on failure and attempt again. if retried + @logger.error("Failed to load solution set - #{e.class}: #{e}") raise else + @logger.debug("Failed to load solution set. Retrying with reverse order.") retried = true solution.reverse! retry diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 736b8bedd..a30cb0e33 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -982,6 +982,15 @@ en: by contacting a plugin author to see if they can address the conflict. %{conflicts} + plugin_init_error: |- + The plugins failed to initialize correctly. If Vagrant was recently + updated, this error may be due to incompatible versions of dependencies. + To fix this problem please remove and re-install all plugins. Vagrant can + attempt to do this automatically by running: + + vagrant plugin expunge --reinstall + + Error message given during initialization: %{message} plugin_load_error: |- The plugins failed to load properly. The error message given is shown below.