Nordstrom / chefdk_bootstrap

Set up your workstation for Chef development in minutes
https://supermarket.chef.io/cookbooks/chefdk_bootstrap
Apache License 2.0
88 stars 44 forks source link

permissions denied installing with Homebrew cask OS X 10.11.6 #150

Open patkaehuaea opened 7 years ago

patkaehuaea commented 7 years ago

I'm able to run bootstrap.rb, but it appears I fail when installing I get permissions errors writing to:

~/Library/Caches/Homebrew/Cask/atom

The workaround is to simply:

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

While the workaround is easy, it leads to a less streamlined bootstrap as the user needs to identify the issue, then apply the workaround.

What are your thoughts about where to implement a fix? Is there something we can do in this cookbook or do we pursue a fix here?:

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

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)
Recipe: atom::mac_os_x
  * homebrew_cask[atom] action install
    * execute[installing cask atom] action run

      ================================================================================
      Error executing action `run` on resource 'execute[installing cask atom]'
      ================================================================================

      Mixlib::ShellOut::ShellCommandFailed
      ------------------------------------
      Expected process to exit with [0], but received '1'
      ---- Begin output of /usr/local/bin/brew cask install atom  ----
      STDOUT: ==> Satisfying dependencies
      complete
      ==> Downloading https://github.com/atom/atom/releases/download/v1.11.1/atom-mac.zip
      STDERR: Error: Download failed on Cask 'atom' with message: Permission denied - /Users/pkaehuae/Library/Caches/Homebrew/Cask/atom--1.11.1.zip.incomplete
      ---- End output of /usr/local/bin/brew cask install atom  ----
      Ran /usr/local/bin/brew cask install atom  returned 1

      Resource Declaration:
      ---------------------
      # In /var/folders/gw/493jck215z5292vrj0vs2004xt283x/T/chefdk_bootstrap-20161012-38299-5mawdl/local-mode-cache/cache/cookbooks/homebrew/providers/cask.rb

       29:   execute "installing cask #{new_resource.name}" do
       30:     command "/usr/local/bin/brew cask install #{new_resource.name} #{new_resource.options}"
       31:     user homebrew_owner
       32:     environment lazy { { 'HOME' => ::Dir.home(homebrew_owner), 'USER' => homebrew_owner } }
       33:     not_if { new_resource.casked? }
       34:   end
       35: end

      Compiled Resource:
      ------------------
      # Declared in /var/folders/gw/493jck215z5292vrj0vs2004xt283x/T/chefdk_bootstrap-20161012-38299-5mawdl/local-mode-cache/cache/cookbooks/homebrew/providers/cask.rb:29:in `block in class_from_file'

      execute("installing cask atom") do
        action [:run]
        retries 0
        retry_delay 2
        default_guard_interpreter :execute
        command "/usr/local/bin/brew cask install atom "
        backup 5
        environment #<Chef::DelayedEvaluator:0x007fcd00a1c730@/var/folders/gw/493jck215z5292vrj0vs2004xt283x/T/chefdk_bootstrap-20161012-38299-5mawdl/local-mode-cache/cache/cookbooks/homebrew/providers/cask.rb:32>
        returns 0
        user "pkaehuae"
        declared_type :execute
        cookbook_name "atom"
        homebrew_owner "pkaehuae"
        not_if { #code block }
      end

      Platform:
      ---------
      x86_64-darwin13

    ================================================================================
    Error executing action `install` on resource 'homebrew_cask[atom]'
    ================================================================================

    Mixlib::ShellOut::ShellCommandFailed
    ------------------------------------
    execute[installing cask atom] (/var/folders/gw/493jck215z5292vrj0vs2004xt283x/T/chefdk_bootstrap-20161012-38299-5mawdl/local-mode-cache/cache/cookbooks/homebrew/providers/cask.rb line 29) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
    ---- Begin output of /usr/local/bin/brew cask install atom  ----
    STDOUT: ==> Satisfying dependencies
    complete
    ==> Downloading https://github.com/atom/atom/releases/download/v1.11.1/atom-mac.zip
    STDERR: Error: Download failed on Cask 'atom' with message: Permission denied - /Users/pkaehuae/Library/Caches/Homebrew/Cask/atom--1.11.1.zip.incomplete
    ---- End output of /usr/local/bin/brew cask install atom  ----
    Ran /usr/local/bin/brew cask install atom  returned 1

    Resource Declaration:
    ---------------------
    # In /var/folders/gw/493jck215z5292vrj0vs2004xt283x/T/chefdk_bootstrap-20161012-38299-5mawdl/local-mode-cache/cache/cookbooks/atom/recipes/mac_os_x.rb

     22: homebrew_cask 'atom'

    Compiled Resource:
    ------------------
    # Declared in /var/folders/gw/493jck215z5292vrj0vs2004xt283x/T/chefdk_bootstrap-20161012-38299-5mawdl/local-mode-cache/cache/cookbooks/atom/recipes/mac_os_x.rb:22:in `from_file'

    homebrew_cask("atom") do
      action [:install]
      retries 0
      retry_delay 2
      default_guard_interpreter :default
      declared_type :homebrew_cask
      cookbook_name "atom"
      recipe_name "mac_os_x"
    end

    Platform:
    ---------
    x86_64-darwin13

Running handlers:
[2016-10-12T11:15:23-07:00] ERROR: Running exception handlers
Running handlers complete
[2016-10-12T11:15:23-07:00] ERROR: Exception handlers complete
Chef Client failed. 2 resources updated in 11 seconds
[2016-10-12T11:15:23-07:00] FATAL: Stacktrace dumped to /var/folders/gw/493jck215z5292vrj0vs2004xt283x/T/chefdk_bootstrap-20161012-38299-5mawdl/local-mode-cache/cache/chef-stacktrace.out
[2016-10-12T11:15:23-07:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-10-12T11:15:23-07:00] ERROR: homebrew_cask[atom] (atom::mac_os_x line 22) had an error: Mixlib::ShellOut::ShellCommandFailed: execute[installing cask atom] (/var/folders/gw/493jck215z5292vrj0vs2004xt283x/T/chefdk_bootstrap-20161012-38299-5mawdl/local-mode-cache/cache/cookbooks/homebrew/providers/cask.rb line 29) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of /usr/local/bin/brew cask install atom  ----
STDOUT: ==> Satisfying dependencies
complete
==> Downloading https://github.com/atom/atom/releases/download/v1.11.1/atom-mac.zip
STDERR: Error: Download failed on Cask 'atom' with message: Permission denied - /Users/pkaehuae/Library/Caches/Homebrew/Cask/atom--1.11.1.zip.incomplete
---- End output of /usr/local/bin/brew cask install atom  ----
Ran /usr/local/bin/brew cask install atom  returned 1
[2016-10-12T11:15:23-07:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
./bootstrap.rb:208:in `run': Chef-client failed (RuntimeError)
    from ./bootstrap.rb:227:in `<main>'
oifland commented 7 years ago

Thanks for providing that workaround, @patkaehuaea. It seems like something that might make sense to fix upstream as you mentioned. I don't have bandwidth right now to pursue the fix, but I'm happy to add vocal support to an upstream fix for the homebrew cookbook.

patkaehuaea commented 7 years ago

@oifland ... https://github.com/chef-cookbooks/homebrew/issues/110

Given they're already setting owner on a similar directory (that doesn't appear to exist for me), I don't see why we couldn't the directory I'm having to update.