$NetBSD: patch-ag,v 1.6 2010/01/27 13:21:58 fhajny Exp $

--- lib/rubygems/uninstaller.rb.orig	2009-05-15 11:32:23.000000000 -0700
+++ lib/rubygems/uninstaller.rb
@@ -55,6 +55,12 @@ class Gem::Uninstaller
     @user_install = false
     @user_install = options[:user_install] unless options[:install_dir]
 
+    install_root = options[:install_root]
+    unless install_root.nil? or install_root == ""
+      @install_root = File.expand_path install_root
+      @gem_home = File.join(@install_root, @gem_home)
+    end
+
     spec_dir = File.join @gem_home, 'specifications'
     @source_index = Gem::SourceIndex.from_gems_in spec_dir
 
@@ -125,6 +131,11 @@ class Gem::Uninstaller
 
     unless spec.executables.empty? then
       bindir = @bin_dir ? @bin_dir : Gem.bindir(spec.installation_path)
+      bindir = @bin_dir ? @bin_dir : Gem.bindir(spec.installation_path, @install_root)
+
+      unless @install_root.nil? or @install_root == ""
+        bindir = File.join(@install_root, bindir)
+      end
 
       list = @source_index.find_name(spec.name).delete_if { |s|
         s.version == spec.version
