Merge pull request #6164 from MikeMcQuaid/better-permissions-errors
Improve permissions errors
This commit is contained in:
commit
7091898014
@ -67,7 +67,7 @@ module Cask
|
|||||||
|
|
||||||
if path.exist? && !path.writable?
|
if path.exist? && !path.writable?
|
||||||
add_error "The staging path #{user_tilde(path.to_s)} is not writable by the current user."
|
add_error "The staging path #{user_tilde(path.to_s)} is not writable by the current user."
|
||||||
add_error "To fix, run \'sudo chown -R ${USER}:staff #{user_tilde(path.to_s)}'"
|
add_error "To fix, run \'sudo chown -R $(whoami):staff #{user_tilde(path.to_s)}'"
|
||||||
end
|
end
|
||||||
|
|
||||||
puts user_tilde(path.to_s)
|
puts user_tilde(path.to_s)
|
||||||
|
@ -289,7 +289,14 @@ class FormulaInstaller
|
|||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
# any exceptions must leave us with nothing installed
|
# any exceptions must leave us with nothing installed
|
||||||
ignore_interrupts do
|
ignore_interrupts do
|
||||||
|
begin
|
||||||
formula.prefix.rmtree if formula.prefix.directory?
|
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
|
formula.rack.rmdir_if_possible
|
||||||
end
|
end
|
||||||
raise if ARGV.homebrew_developer? ||
|
raise if ARGV.homebrew_developer? ||
|
||||||
|
@ -310,8 +310,11 @@ class Keg
|
|||||||
remove_opt_record if optlinked?
|
remove_opt_record if optlinked?
|
||||||
remove_old_aliases
|
remove_old_aliases
|
||||||
remove_oldname_opt_record
|
remove_oldname_opt_record
|
||||||
rescue Errno::ENOTEMPTY
|
rescue Errno::EACCES, Errno::ENOTEMPTY
|
||||||
ofail "Could not remove #{path}! Check its permissions."
|
odie <<~EOS
|
||||||
|
Could not remove #{name} keg! Do so manually:
|
||||||
|
sudo rm -rf #{path}
|
||||||
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
def unlink(mode = OpenStruct.new)
|
def unlink(mode = OpenStruct.new)
|
||||||
|
@ -45,12 +45,26 @@ module Homebrew
|
|||||||
ignore_interrupts { restore_backup(keg, keg_was_linked) }
|
ignore_interrupts { restore_backup(keg, keg_was_linked) }
|
||||||
raise
|
raise
|
||||||
else
|
else
|
||||||
|
begin
|
||||||
backup_path(keg).rmtree if backup_path(keg).exist?
|
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
|
end
|
||||||
|
|
||||||
def backup(keg)
|
def backup(keg)
|
||||||
keg.unlink
|
keg.unlink
|
||||||
|
begin
|
||||||
keg.rename backup_path(keg)
|
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
|
end
|
||||||
|
|
||||||
def restore_backup(keg, keg_was_linked)
|
def restore_backup(keg, keg_was_linked)
|
||||||
|
@ -116,7 +116,7 @@ If you ever did a `sudo gem`, etc. before then a lot of files will have
|
|||||||
been created owned by root. Fix with:
|
been created owned by root. Fix with:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
sudo chown -R $USER /Library/Ruby /Library/Perl /Library/Python
|
sudo chown -R $(whoami) /Library/Ruby /Library/Perl /Library/Python
|
||||||
```
|
```
|
||||||
|
|
||||||
## Perl CPAN modules without sudo
|
## Perl CPAN modules without sudo
|
||||||
|
Loading…
x
Reference in New Issue
Block a user