diff --git a/Library/Homebrew/cmd/uninstall.rb b/Library/Homebrew/cmd/uninstall.rb index a7b426c0c4..91551c4424 100644 --- a/Library/Homebrew/cmd/uninstall.rb +++ b/Library/Homebrew/cmd/uninstall.rb @@ -11,7 +11,6 @@ module Homebrew puts "Uninstalling #{keg}..." keg.unlink keg.uninstall - rm_opt_link keg.fname rm_pin keg.fname end end @@ -29,7 +28,6 @@ module Homebrew end end - rm_opt_link name rm_pin name end end @@ -38,11 +36,6 @@ module Homebrew puts "Use `brew remove --force #{e.name}` to remove all versions." end - def rm_opt_link name - optlink = HOMEBREW_PREFIX.join("opt", name) - optlink.unlink if optlink.symlink? - end - def rm_pin name Formulary.factory(name).unpin rescue nil end diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 8113a36a9e..deb22402b3 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -97,6 +97,12 @@ class Keg < Pathname def uninstall rmtree parent.rmdir_if_possible + + opt = HOMEBREW_PREFIX.join("opt", fname) + if opt.symlink? && self == opt.resolved_path + opt.unlink + opt.parent.rmdir_if_possible + end end def unlink