diff --git a/lib/cask.rb b/lib/cask.rb index cd416d571c..132de309cf 100644 --- a/lib/cask.rb +++ b/lib/cask.rb @@ -45,11 +45,11 @@ class Cask ohai "We'll set permissions properly so we won't need sudo in the future" current_user = ENV['USER'] if caskroom.parent.writable? - system "mkdir #{caskroom}" + system "/bin/mkdir #{caskroom}" else # sudo in system is rude. - system "sudo mkdir -p #{caskroom}" - system "sudo chown -R #{current_user}:staff #{caskroom.parent}" + system "/usr/bin/sudo /bin/mkdir -p #{caskroom}" + system "/usr/bin/sudo /usr/sbin/chown -R #{current_user}:staff #{caskroom.parent}" end end appdir.mkpath unless appdir.exist? diff --git a/lib/cask/cli/home.rb b/lib/cask/cli/home.rb index 481c2006a5..bac0cab5b6 100644 --- a/lib/cask/cli/home.rb +++ b/lib/cask/cli/home.rb @@ -3,7 +3,7 @@ module Cask::CLI::Home raise CaskUnspecifiedError if cask_names.empty? cask_names.each do |cask_name| cask = Cask.load(cask_name) - system "open", cask.homepage + system "/usr/bin/open", cask.homepage end end diff --git a/lib/cask/system_command.rb b/lib/cask/system_command.rb index 475cc05031..d39592f6ed 100644 --- a/lib/cask/system_command.rb +++ b/lib/cask/system_command.rb @@ -26,7 +26,7 @@ class Cask::SystemCommand def self._process_options(command, options) if options[:sudo] - command = "sudo -E #{_quote(command)}" + command = "/usr/bin/sudo -E #{_quote(command)}" end if options[:args] command = "#{command} #{options[:args].map { |arg| _quote(arg) }.join(' ')}" diff --git a/test/cask/artifact/pkg_test.rb b/test/cask/artifact/pkg_test.rb index 8b32473999..8dad93fa5d 100644 --- a/test/cask/artifact/pkg_test.rb +++ b/test/cask/artifact/pkg_test.rb @@ -12,7 +12,7 @@ describe Cask::Artifact::Pkg do it 'runs the system installer on the specified pkgs' do pkg = Cask::Artifact::Pkg.new(@cask, Cask::FakeSystemCommand) - expected_command = "sudo -E '/usr/sbin/installer' '-pkg' '#{@cask.destination_path/'MyFancyPkg'/'Fancy.pkg'}' '-target' '/' 2>&1" + expected_command = "/usr/bin/sudo -E '/usr/sbin/installer' '-pkg' '#{@cask.destination_path/'MyFancyPkg'/'Fancy.pkg'}' '-target' '/' 2>&1" Cask::FakeSystemCommand.stubs_command(expected_command) shutup do @@ -27,10 +27,10 @@ describe Cask::Artifact::Pkg do it 'runs the specified uninstaller for the cask' do pkg = Cask::Artifact::Pkg.new(@cask, Cask::FakeSystemCommand) - Cask::FakeSystemCommand.stubs_command(%Q(sudo -E '/usr/bin/osascript' '-e' 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"' 2>&1), '1') - Cask::FakeSystemCommand.stubs_command(%Q(sudo -E '/usr/bin/osascript' '-e' 'tell application id "my.fancy.package.app" to quit' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/usr/bin/osascript' '-e' 'tell application "System Events" to count processes whose bundle identifier is "my.fancy.package.app"' 2>&1), '1') + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/usr/bin/osascript' '-e' 'tell application id "my.fancy.package.app" to quit' 2>&1)) - expected_command = "sudo -E '#{@cask.destination_path/'MyFancyPkg'/'FancyUninstaller.tool'}' '--please' 2>&1" + expected_command = "/usr/bin/sudo -E '#{@cask.destination_path/'MyFancyPkg'/'FancyUninstaller.tool'}' '--please' 2>&1" Cask::FakeSystemCommand.stubs_command(expected_command) shutup do @@ -82,9 +82,9 @@ describe Cask::Artifact::Pkg do PLIST ) - Cask::FakeSystemCommand.stubs_command(%Q(sudo -E '/usr/sbin/kextstat' '-l' '-b' 'my.fancy.package.kernelextension' 2>&1), 'loaded') - Cask::FakeSystemCommand.expects_command(%Q(sudo -E '/sbin/kextunload' '-b' 'my.fancy.package.kernelextension' 2>&1)) - Cask::FakeSystemCommand.stubs_command(%Q(sudo -E '/usr/sbin/pkgutil' '--forget' 'my.fancy.package.main' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/usr/sbin/kextstat' '-l' '-b' 'my.fancy.package.kernelextension' 2>&1), 'loaded') + Cask::FakeSystemCommand.expects_command(%Q(/usr/bin/sudo -E '/sbin/kextunload' '-b' 'my.fancy.package.kernelextension' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/usr/sbin/pkgutil' '--forget' 'my.fancy.package.main' 2>&1)) Cask::FakeSystemCommand.stubs_command( %Q(/usr/sbin/pkgutil '--only-files' '--files' 'my.fancy.package.agent' 2>&1), @@ -123,13 +123,13 @@ describe Cask::Artifact::Pkg do /tmp/fancy/bin /tmp/fancy/var ].each do |dir| - Cask::FakeSystemCommand.stubs_command(%Q(sudo -E '/bin/chmod' '777' '#{dir}' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/bin/chmod' '777' '#{dir}' 2>&1)) end - Cask::FakeSystemCommand.stubs_command(%Q(sudo -E '/usr/sbin/pkgutil' '--forget' 'my.fancy.package.agent' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/usr/sbin/pkgutil' '--forget' 'my.fancy.package.agent' 2>&1)) - Cask::FakeSystemCommand.stubs_command(%Q(sudo -E '/bin/rm' '-f' '/tmp/fancy/bin/fancy.exe' '/tmp/fancy/var/fancy.data' 2>&1)) - Cask::FakeSystemCommand.stubs_command(%Q(sudo -E '/bin/rm' '-f' '/tmp/fancy/agent/fancy-agent.exe' '/tmp/fancy/agent/fancy-agent.pid' '/tmp/fancy/agent/fancy-agent.log' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/bin/rm' '-f' '/tmp/fancy/bin/fancy.exe' '/tmp/fancy/var/fancy.data' 2>&1)) + Cask::FakeSystemCommand.stubs_command(%Q(/usr/bin/sudo -E '/bin/rm' '-f' '/tmp/fancy/agent/fancy-agent.exe' '/tmp/fancy/agent/fancy-agent.pid' '/tmp/fancy/agent/fancy-agent.log' 2>&1)) # No assertions after call since all assertions are implicit from the interactions setup above. # TODO: verify rmdir commands (requires setting up actual file tree or faking out .exists? diff --git a/test/cask/cli/home_test.rb b/test/cask/cli/home_test.rb index ebb4f21e7a..bb03ddb644 100644 --- a/test/cask/cli/home_test.rb +++ b/test/cask/cli/home_test.rb @@ -26,15 +26,15 @@ describe Cask::CLI::Home do it 'opens the homepage for the specified cask' do Cask::CLI::Home.run('alfred') Cask::CLI::Home.system_commands.must_equal [ - ['open', 'http://www.alfredapp.com/'] + ['/usr/bin/open', 'http://www.alfredapp.com/'] ] end it 'works for multiple casks' do Cask::CLI::Home.run('alfred', 'adium') Cask::CLI::Home.system_commands.must_equal [ - ['open', 'http://www.alfredapp.com/'], - ['open', 'https://www.adium.im/'] + ['/usr/bin/open', 'http://www.alfredapp.com/'], + ['/usr/bin/open', 'https://www.adium.im/'] ] end diff --git a/test/cask/pkg_test.rb b/test/cask/pkg_test.rb index e483f9f533..6c201f50b7 100644 --- a/test/cask/pkg_test.rb +++ b/test/cask/pkg_test.rb @@ -30,7 +30,7 @@ describe Cask::Pkg do ) Cask::FakeSystemCommand.expects_command( - %q(sudo -E '/usr/sbin/pkgutil' '--forget' 'my.fake.pkg' 2>&1) + %q(/usr/bin/sudo -E '/usr/sbin/pkgutil' '--forget' 'my.fake.pkg' 2>&1) ) pkg.uninstall