chown can only be run as root

The logic here was flawed -- my caskroom.parent was writeable, but chown
was called regardless, causing an error.
This commit is contained in:
James Felix Black 2014-01-08 11:22:32 -08:00
parent c17fd52cd3
commit 83d5e7dfe4

View file

@ -40,9 +40,13 @@ class Cask
ohai "We need to make Caskroom for the first time at #{caskroom}"
ohai "We'll set permissions properly so we won't need sudo in the future"
current_user = ENV['USER']
sudo = 'sudo' unless caskroom.parent.writable?
system "#{sudo} mkdir -p #{caskroom}"
system "#{sudo} chown -R #{current_user}:staff #{caskroom.parent}"
if caskroom.parent.writable?
system "mkdir #{caskroom}"
else
# sudo in system is rude.
system "sudo mkdir -p #{caskroom}"
system "sudo chown -R #{current_user}:staff #{caskroom.parent}"
end
end
appdir.mkpath unless appdir.exist?
qlplugindir.mkpath unless qlplugindir.exist?