sous-chefs / homebrew

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

package upgrade doesn't install if not installed #58

Closed simmel closed 9 years ago

simmel commented 9 years ago

According to http://docs.getchef.com/resource_homebrew_package.html#actions package 'mysql' action :upgrade end should install the package if it isn't installed, but this is not the case:

[…]
    ---- Begin output of brew upgrade mtr ----
    STDOUT:
    STDERR: Error: mtr not installed
    ---- End output of brew upgrade mtr ----
[…]

Maybe running and parsing brew info --json=v1 mtr before installing or upgrading would be a solution? Then we could get rid of the whole stacktrace and the need to use ignore_failure true because we're installing applications which is already installed.

If the 'installed' array is empty it's not installed:

$ brew info --json=v1 mtr | jq '.[0].installed'
[]

and if it's not empty it lists the version installed:

$ brew info --json=v1 jq | jq '.[0].installed'
[
  {
    "version": "1.4",
    "used_options": [],
    "built_as_bottle": null,
    "poured_from_bottle": false
  }
]
jtimberman commented 9 years ago

What version of Chef are you using? What version of the homebrew cookbook?

In Chef 12, homebrew's package provider is the default for OS X. Can you try with Chef 12? The implementation of the upgrade action is different.

https://github.com/opscode/chef/blob/master/lib/chef/provider/package/homebrew.rb#L52-L60

jtimberman commented 9 years ago

This is fixed in #55.

jtimberman commented 9 years ago

"fixed" in that it isn't a problem using the homebrew provider in Chef 12.

simmel commented 9 years ago

(for the history: me and @jtimberman talked and resolved the issue on/over IRC. I'm just lagging to reply to this issue and close it. Thanks!)