From 635949980b11b49dd8b68169d205ed6fe524bbf6 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 3 Feb 2013 14:29:29 -0800 Subject: [PATCH] Handle the case a plugin install is a plugin not found --- lib/vagrant/errors.rb | 4 ++++ plugins/commands/plugin/action/install_gem.rb | 8 +++++++- templates/locales/en.yml | 3 +++ 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/vagrant/errors.rb b/lib/vagrant/errors.rb index 1eeaf686f..2f50cc8e7 100644 --- a/lib/vagrant/errors.rb +++ b/lib/vagrant/errors.rb @@ -344,6 +344,10 @@ module Vagrant error_key(:plugin_install_bad_entry_point) end + class PluginInstallNotFound < VagrantError + error_key(:plugin_install_not_found) + end + class PluginLoadError < VagrantError status_code(81) error_key(:plugin_load_error) diff --git a/plugins/commands/plugin/action/install_gem.rb b/plugins/commands/plugin/action/install_gem.rb index 6f5f30473..88c99b284 100644 --- a/plugins/commands/plugin/action/install_gem.rb +++ b/plugins/commands/plugin/action/install_gem.rb @@ -22,7 +22,13 @@ module VagrantPlugins :name => plugin_name)) installed_gems = env[:gem_helper].with_environment do installer = Gem::DependencyInstaller.new(:document => []) - installer.install(plugin_name) + + begin + installer.install(plugin_name) + rescue Gem::GemNotFoundException + raise Vagrant::Errors::PluginInstallNotFound, + :name => plugin_name + end end # The plugin spec is the last installed gem since RubyGems diff --git a/templates/locales/en.yml b/templates/locales/en.yml index e50f67159..b34e860c8 100644 --- a/templates/locales/en.yml +++ b/templates/locales/en.yml @@ -175,6 +175,9 @@ en: the entry point doesn't exist. The entry point attempted was '%{entry_point}'. If this is not correct, please manually specify an `--entry-point` when installing the plugin. + plugin_install_not_found: |- + The plugin '%{name}' could not be found in local or remote + repositories. Please check the name of the plugin and try again. plugin_load_error: |- The plugin "%{plugin}" could not be found. Please make sure that it is properly installed via `vagrant plugin`.