From e1c0c48ffaf7224655c8251a4ec3097cfd29b8c7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sun, 28 Jul 2013 21:38:48 -0700 Subject: [PATCH] Show the correct installed plugin [GH-1834] --- CHANGELOG.md | 2 ++ plugins/commands/plugin/action/install_gem.rb | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ef76bc7a..dfc5fde49 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,8 @@ BUG FIXES: - Make sure the hostname configuration is a string. [GH-1999] - cURL downloads now contain a user agent which fixes some issues with downloading Vagrant through proxies. [GH-2003] + - `vagrant plugin install` will now always properly show the actual + installed gem name. [GH-1834] ## 1.2.6 (July 26, 2013) diff --git a/plugins/commands/plugin/action/install_gem.rb b/plugins/commands/plugin/action/install_gem.rb index dba41d545..4769fe524 100644 --- a/plugins/commands/plugin/action/install_gem.rb +++ b/plugins/commands/plugin/action/install_gem.rb @@ -1,5 +1,6 @@ require "rubygems" require "rubygems/dependency_installer" +require "rubygems/format" require "log4r" @@ -19,6 +20,16 @@ module VagrantPlugins prerelease = env[:plugin_prerelease] version = env[:plugin_version] + # Determine the plugin name we'll look for in the installed set + # in order to determine the version and all that. + find_plugin_name = plugin_name + if plugin_name =~ /\.gem$/ + # If we're installing from a gem file, determine the name + # based on the spec in the file. + pkg = Gem::Format.from_file_by_path(plugin_name) + find_plugin_name = pkg.spec.name + end + # Install the gem plugin_name_label = plugin_name plugin_name_label += ' --prerelease' if prerelease @@ -45,7 +56,9 @@ module VagrantPlugins # The plugin spec is the last installed gem since RubyGems # currently always installed the requested gem last. @logger.debug("Installed #{installed_gems.length} gems.") - plugin_spec = installed_gems.last + plugin_spec = installed_gems.find do |gem| + gem.name.downcase == find_plugin_name.downcase + end # Store the installed name so we can uninstall it if things go # wrong.