From 55b81eb9e659f641edd0c73aa504c7d35970ad8a Mon Sep 17 00:00:00 2001 From: drbrain Date: Wed, 27 Jul 2011 03:33:45 +0000 Subject: * lib/rubygems/uninstaller.rb: Add missing require and update messaging to avoid confusion with uninstall --format-executable. [Ruby 1.9 - Bug #4062] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32697 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/rubygems/uninstaller.rb | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/rubygems/uninstaller.rb b/lib/rubygems/uninstaller.rb index 8940980886..cc32ea48c4 100644 --- a/lib/rubygems/uninstaller.rb +++ b/lib/rubygems/uninstaller.rb @@ -70,7 +70,7 @@ class Gem::Uninstaller list = Gem::Specification.find_all_by_name(@gem, @version) if list.empty? then - raise Gem::InstallError, "cannot uninstall, check `gem list -d #{@gem}`" + raise Gem::InstallError, "gem #{@gem.inspect} is not installed" elsif list.size > 1 and @force_all then remove_all list @@ -141,9 +141,11 @@ class Gem::Uninstaller return if executables.empty? + executables = executables.map { |exec| formatted_program_filename exec } + remove = if @force_executables.nil? then ask_yes_no("Remove executables:\n" \ - "\t#{spec.executables.join ', '}\n\n" \ + "\t#{executables.join ', '}\n\n" \ "in addition to the gem?", true) else @@ -153,14 +155,17 @@ class Gem::Uninstaller unless remove then say "Executables and scripts will remain installed." else - bindir = @bin_dir || Gem.bindir(spec.base_dir) + bin_dir = @bin_dir || Gem.bindir(spec.base_dir) - raise Gem::FilePermissionError, bindir unless File.writable? bindir + raise Gem::FilePermissionError, bin_dir unless File.writable? bin_dir - spec.executables.each do |exe_name| + executables.each do |exe_name| say "Removing #{exe_name}" - FileUtils.rm_f File.join(bindir, formatted_program_filename(exe_name)) - FileUtils.rm_f File.join(bindir, "#{formatted_program_filename(exe_name)}.bat") + + exe_file = File.join bin_dir, exe_name + + FileUtils.rm_f exe_file + FileUtils.rm_f "#{exe_file}.bat" end end end @@ -257,6 +262,7 @@ class Gem::Uninstaller def formatted_program_filename(filename) if @format_executable then + require 'rubygems/installer' Gem::Installer.exec_format % File.basename(filename) else filename -- cgit v1.2.3