sous-chefs/homebrew

package upgrade doesn't install if not installed

simmel opened this issue · 4 comments

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
  }
]

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

This is fixed in #55.

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

(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!)