diff --git a/lib/vagrant/action/builtin/box_check_outdated.rb b/lib/vagrant/action/builtin/box_check_outdated.rb index 87d19a5df..135da550c 100644 --- a/lib/vagrant/action/builtin/box_check_outdated.rb +++ b/lib/vagrant/action/builtin/box_check_outdated.rb @@ -20,6 +20,11 @@ module Vagrant if !machine.config.vm.box_check_update return @app.call(env) end + + if !env.has_key?(:box_outdated_refresh) + env[:box_outdated_refresh] = true + env[:box_outdated_ignore_errors] = true + end end if !machine.box @@ -30,9 +35,17 @@ module Vagrant end if env[:box_outdated_refresh] - @logger.info( - "Checking if box is outdated by refreshing metadata") - check_outdated_refresh(env) + env[:ui].output(I18n.t( + "vagrant.box_outdated_checking_with_refresh", + name: machine.box.name)) + begin + check_outdated_refresh(env) + rescue Errors::VagrantError => e + raise if !env[:box_outdated_ignore_errors] + env[:ui].detail(I18n.t( + "vagrant.box_outdated_metadata_error", + message: e.message)) + end else @logger.info("Checking if box is outdated locally") check_outdated_local(env) diff --git a/plugins/providers/virtualbox/action.rb b/plugins/providers/virtualbox/action.rb index 34b1b08e0..5339343f1 100644 --- a/plugins/providers/virtualbox/action.rb +++ b/plugins/providers/virtualbox/action.rb @@ -307,6 +307,7 @@ module VagrantPlugins end b.use ConfigValidate + b.use BoxCheckOutdated b.use Call, Created do |env, b2| # If the VM is NOT created yet, then do the setup steps if !env[:result] diff --git a/templates/locales/en.yml b/templates/locales/en.yml index f41d6e559..518640c3a 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -30,11 +30,16 @@ en: Loading metadata for box '%{name}' box_outdated: |- * '%{name}' is outdated! Current: %{current}. Latest: %{latest} + box_outdated_checking_with_refresh: |- + Checking if box '%{name}' is up to date... box_outdated_local: |- A newer version of the box '%{name}' is available and already installed, but your Vagrant machine is running against version '%{old}'. To update to version '%{new}', destroy and recreate your machine. + box_outdated_metadata_error: |- + Error loading box metadata while attempting to check for + updates: %{message} box_outdated_single: |- A newer version of the box '%{name}' is available! You currently have version '%{current}'. The latest is version '%{latest}'. Run