sous-chefs / homebrew

Development repository for the homebrew cookbook
https://supermarket.chef.io/cookbooks/homebrew
Apache License 2.0
152 stars 136 forks source link

permissions denied running brew cask install <app_name> after fresh cask install #110

Closed patkaehuaea closed 7 years ago

patkaehuaea commented 8 years ago

Cookbook version

2.1.2

Chef-client version

Chef: 12.14.89

Platform Details

OS X El Capitan Version 10.11.6

Scenario:

TLDR: /usr/local/bin/brew cask install atom is failing because it doesn't have permissions to ~/Library/Caches/Homebrew/Cask/atom

I'm running Nordstrom/chefdk_bootstrap. One of the steps is to run the homebrew::cask recipe:

Recipe: homebrew::cask
  * homebrew_tap[caskroom/cask] action tap
    * execute[tapping caskroom/cask] action run (skipped due to not_if)
     (up to date)
  * directory[/Library/Caches/Homebrew/Casks] action create (skipped due to only_if)

The install succeeds, but subsequent calls to /usr/local/bin/brew cask install fail:

$ /usr/local/bin/brew cask install atom
==> Satisfying dependencies
complete
==> Downloading https://github.com/atom/atom/releases/download/v1.11.1/atom-mac.zip
Error: Download failed on Cask 'atom' with message: Permission denied - /Users/pkaehuae/Library/Caches/Homebrew/Cask/atom--1.11.1.zip.incomplete

The workaround is to:

$ sudo chown -R $USER ~/Library/Caches/Homebrew/

While this remediates the issue, I feel like a better fix would be to add a block similar to the one below, but for ~/Library/Caches/Homebrew/ in addition to the one listed:

https://github.com/chef-cookbooks/homebrew/blob/master/recipes/cask.rb#L23-L27

Steps to Reproduce:

  1. Run this line https://github.com/Nordstrom/chefdk_bootstrap/blob/master/recipes/mac_os_x.rb#L29 on a system that does not have Homebrew or Cask installed.
  2. Run /usr/local/bin/brew cask install atom.
  3. Verify error Error: Download failed on Cask 'atom' with message: Permission denied - /Users/pkaehuae/Library/Caches/Homebrew/Cask/atom--1.11.1.zip.incomplete
  4. Run sudo chown -R $USER ~/Library/Caches/Homebrew/
  5. Attempt atom install again: /usr/local/bin/brew cask install atom
  6. Verify success.

    Expected Result:

This is successful: /usr/local/bin/brew cask install atom

Actual Result:

Error: Download failed on Cask 'atom' with message: Permission denied - /Users/pkaehuae/Library/Caches/Homebrew/Cask/atom--1.11.1.zip.incomplete

oifland commented 8 years ago

I've heard a second report of this in the wild

tas50 commented 7 years ago

I believe we've fixed this in the 4.0 release. Give it a try and feel free to open this back up if you're still seeing the issue