From 83d5e7dfe429e2ec7f5d35aae00a7f552e499820 Mon Sep 17 00:00:00 2001 From: James Felix Black Date: Wed, 8 Jan 2014 11:22:32 -0800 Subject: [PATCH] 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. --- lib/cask.rb | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/cask.rb b/lib/cask.rb index 29599cf29..c8b3e25ca 100644 --- a/lib/cask.rb +++ b/lib/cask.rb @@ -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?