diff --git a/lib/vagrant/action/builtin/box_remove.rb b/lib/vagrant/action/builtin/box_remove.rb index faa1d685c..0314a9ea0 100644 --- a/lib/vagrant/action/builtin/box_remove.rb +++ b/lib/vagrant/action/builtin/box_remove.rb @@ -65,6 +65,14 @@ module Vagrant box = env[:box_collection].find( box_name, box_provider, box_version) + if box == nil + raise Errors::BoxRemoveVersionNotFound, + name: box_name, + provider: box_provider.to_s, + version: box_version, + versions: all_versions.join(", ") + end + env[:ui].info(I18n.t("vagrant.commands.box.removing", :name => box.name, :provider => box.provider)) diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index b6dc0716d..1aa277b05 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -196,6 +196,10 @@ module Vagrant error_key(:box_remove_provider_not_found) end + class BoxRemoveVersionNotFound < VagrantError + error_key(:box_remove_version_not_found) + end + class BoxRemoveMultiProvider < VagrantError error_key(:box_remove_multi_provider) end diff --git a/templates/locales/en.yml b/templates/locales/en.yml index 5e9afe7c8..c122eff2a 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -433,6 +433,13 @@ en: the provider specified. Please double-check and try again. The providers for this are: %{providers} + box_remove_version_not_found: |- + You requested to remove the box '%{name}' with provider + '%{provider}' in version '%{version}'. The box '%{name}' + exists but not in the specified version '%{version}'. + Please double-check and try again. + + The available versions for this box are: %{versions} box_server_not_set: |- A URL to a Vagrant Cloud server is not set, so boxes cannot be added with a shorthand ("mitchellh/precise64") format.