From e1c94310857fc219b0e6e10a92a27353e8fcf59e Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 5 Jan 2014 16:02:00 -0800 Subject: [PATCH] commands/plugin: uninstall works again --- lib/vagrant/bundler.rb | 14 ++++++++++---- lib/vagrant/plugin/manager.rb | 10 ++++++++++ plugins/commands/plugin/action/uninstall_plugin.rb | 4 +++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/lib/vagrant/bundler.rb b/lib/vagrant/bundler.rb index 956735be1..3dc7b4514 100644 --- a/lib/vagrant/bundler.rb +++ b/lib/vagrant/bundler.rb @@ -67,13 +67,19 @@ module Vagrant ::Bundler::Installer.install(root, definition, opts) end - # Clean up any unused/old gems - runtime = ::Bundler::Runtime.new(root, definition) - #runtime.clean - definition.specs end + # Clean removes any unused gems. + def clean(plugins) + gemfile = build_gemfile(plugins) + lockfile = "#{gemfile.path}.lock" + definition = ::Bundler::Definition.build(gemfile, lockfile, nil) + root = File.dirname(gemfile.path) + runtime = ::Bundler::Runtime.new(root, definition) + runtime.clean + end + # Builds a valid Gemfile for use with Bundler given the list of # plugins. # diff --git a/lib/vagrant/plugin/manager.rb b/lib/vagrant/plugin/manager.rb index 3f7d5beb9..a4ccce8fb 100644 --- a/lib/vagrant/plugin/manager.rb +++ b/lib/vagrant/plugin/manager.rb @@ -40,6 +40,16 @@ module Vagrant result end + # Uninstalls the plugin with the given name. + # + # @param [String] name + def uninstall_plugin(name) + @global_file.remove_plugin(name) + + # Clean the environment, removing any old plugins + Vagrant::Bundler.instance.clean(installed_plugins) + end + # This returns the list of plugins that should be enabled. # # @return [Array] diff --git a/plugins/commands/plugin/action/uninstall_plugin.rb b/plugins/commands/plugin/action/uninstall_plugin.rb index f86675523..acf1ef2a3 100644 --- a/plugins/commands/plugin/action/uninstall_plugin.rb +++ b/plugins/commands/plugin/action/uninstall_plugin.rb @@ -13,7 +13,9 @@ module VagrantPlugins # Remove it! env[:ui].info(I18n.t("vagrant.commands.plugin.uninstalling", :name => env[:plugin_name])) - env[:plugin_state_file].remove_plugin(env[:plugin_name]) + + manager = Vagrant::Plugin::Manager.instance + manager.uninstall_plugin(env[:plugin_name]) @app.call(env) end