reinstall: handle remove/rename permission errors.
This commit is contained in:
parent
8908dc51d6
commit
4759ffb88f
@ -289,7 +289,14 @@ class FormulaInstaller
|
||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||
# any exceptions must leave us with nothing installed
|
||||
ignore_interrupts do
|
||||
formula.prefix.rmtree if formula.prefix.directory?
|
||||
begin
|
||||
formula.prefix.rmtree if formula.prefix.directory?
|
||||
rescue Errno::EACCES, Errno::ENOTEMPTY
|
||||
odie <<~EOS
|
||||
Could not remove #{formula.prefix.basename} keg! Do so manually:
|
||||
sudo rm -rf #{formula.prefix}
|
||||
EOS
|
||||
end
|
||||
formula.rack.rmdir_if_possible
|
||||
end
|
||||
raise if ARGV.homebrew_developer? ||
|
||||
|
||||
@ -310,7 +310,7 @@ class Keg
|
||||
remove_opt_record if optlinked?
|
||||
remove_old_aliases
|
||||
remove_oldname_opt_record
|
||||
rescue Errno::ENOTEMPTY
|
||||
rescue Errno::EACCES, Errno::ENOTEMPTY
|
||||
odie <<~EOS
|
||||
Could not remove #{name} keg! Do so manually:
|
||||
sudo rm -rf #{path}
|
||||
|
||||
@ -45,12 +45,26 @@ module Homebrew
|
||||
ignore_interrupts { restore_backup(keg, keg_was_linked) }
|
||||
raise
|
||||
else
|
||||
backup_path(keg).rmtree if backup_path(keg).exist?
|
||||
begin
|
||||
backup_path(keg).rmtree if backup_path(keg).exist?
|
||||
rescue Errno::EACCES, Errno::ENOTEMPTY
|
||||
odie <<~EOS
|
||||
Could not remove #{backup_path(keg).parent.basename} backup keg! Do so manually:
|
||||
sudo rm -rf #{backup_path(keg)}
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
def backup(keg)
|
||||
keg.unlink
|
||||
keg.rename backup_path(keg)
|
||||
begin
|
||||
keg.rename backup_path(keg)
|
||||
rescue Errno::EACCES, Errno::ENOTEMPTY
|
||||
odie <<~EOS
|
||||
Could not rename #{keg.name} keg! Check/fix its permissions:
|
||||
sudo chown -R $(whoami) #{keg}
|
||||
EOS
|
||||
end
|
||||
end
|
||||
|
||||
def restore_backup(keg, keg_was_linked)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user