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

homebrew_cask LWRP fails when checking if package is already installed! #78

Closed nickvanw closed 8 years ago

nickvanw commented 9 years ago

Chef Client version 12.4.3

Run output:

    * execute[installing cask spotify] action run

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

      NoMethodError
      -------------
      undefined method `casked' for nil:NilClass

      Cookbook Trace:
      ---------------
      /var/chef/cache/cookbooks/homebrew/providers/cask.rb:40:in `block (3 levels) in class_from_file'

      Resource Declaration:
      ---------------------
      # In /var/chef/cache/cookbooks/homebrew/providers/cask.rb

       37:   execute "installing cask #{new_resource.name}" do
       38:     command "/usr/local/bin/brew cask install #{new_resource.name} #{new_resource.options}"
       39:     user homebrew_owner
       40:     not_if { @cask.casked }
       41:   end
       42: end

      Compiled Resource:
      ------------------
      # Declared in /var/chef/cache/cookbooks/homebrew/providers/cask.rb:37:in `block in class_from_file'

      execute("installing cask spotify") do
        action [:run]
        retries 0
        retry_delay 2
        default_guard_interpreter :execute
        command "/usr/local/bin/brew cask install spotify "
        backup 5
        returns 0
        user "nick"
        declared_type :execute
        cookbook_name "workstation"
        homebrew_owner "nick"
        not_if { #code block }
      end

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

    NoMethodError
    -------------
    execute[installing cask spotify] (/var/chef/cache/cookbooks/homebrew/providers/cask.rb line 37) had an error: NoMethodError: undefined method `casked' for nil:NilClass

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/homebrew/providers/cask.rb:40:in `block (3 levels) in class_from_file'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/workstation/recipes/packages.rb

     42:   homebrew_cask p
     43: end

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/workstation/recipes/packages.rb:42:in `block in from_file'

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

Running handlers:
[2015-09-27T15:02:53-04:00] ERROR: Running exception handlers
Running handlers complete
[2015-09-27T15:02:53-04:00] ERROR: Exception handlers complete
Chef Client failed. 1 resources updated in 10.01444 seconds
[2015-09-27T15:02:53-04:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2015-09-27T15:02:53-04:00] ERROR: homebrew_cask[spotify] (workstation::packages line 42) had an error: NoMethodError: execute[installing cask spotify] (/var/chef/cache/cookbooks/homebrew/providers/cask.rb line 37) had an error: NoMethodError: undefined method `casked' for nil:NilClass
[2015-09-27T15:02:53-04:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Gaelan commented 9 years ago

:+1:

SteveMarshall commented 8 years ago

From some initial investigation, this appears to be because https://github.com/chef-cookbooks/homebrew/blob/master/providers/cask.rb#L40 is @cask.casked, and it should be new_resource.casked (I think?).

I'll try to open a PR.

bcg62 commented 8 years ago

+1 also having this issue

tas50 commented 8 years ago

This is fixed in the 2.0.1 release