diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 145be9e22a..fc3554def1 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -249,7 +249,7 @@ module Homebrew end def cleanup_keg(keg) - cleanup_path(keg) { keg.uninstall } + cleanup_path(keg) { keg.uninstall(raise_failures: true) } rescue Errno::EACCES => e opoo e.message unremovable_kegs << keg diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index 97318f9ac3..45dfb71a2c 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -319,7 +319,7 @@ class Keg opt_record.parent.rmdir_if_possible end - def uninstall + def uninstall(raise_failures: false) CacheStoreDatabase.use(:linkage) do |db| break unless db.created? @@ -333,6 +333,8 @@ class Keg remove_old_aliases remove_oldname_opt_record rescue Errno::EACCES, Errno::ENOTEMPTY + raise if raise_failures + odie <<~EOS Could not remove #{name} keg! Do so manually: sudo rm -rf #{path}