Unverified Commit ca999a81 authored by Issy Long's avatar Issy Long
Browse files

dev-cmd/unbottled: Fail nicely if analytics data can't be retrieved

- When testing `brew unbottled <formula>` this crashed because I, as a
  maintainer, have `HOMEBREW_NO_ANALYTICS` set on all my machines to
  avoid polluting the analytics with test installs.

❯ brew unbottled
==> Getting formulae...
==> Getting analytics data...
Error: undefined method `[]' for nil:NilClass
/usr/local/Homebrew/Library/Homebrew/dev-cmd/unbottled.rb:89:in `formulae_all_sort_installs_from_args'
/usr/local/Homebrew/Library/Homebrew/dev-cmd/unbottled.rb:49:in `unbottled'
/usr/local/Homebrew/Library/Homebrew/brew.rb:119:in `<main>'
parent 5786a893
......@@ -86,6 +86,13 @@ module Homebrew
ohai "Getting analytics data..."
analytics = Utils::Analytics.formulae_brew_sh_json("analytics/install/90d.json")
if analytics.blank?
raise UsageError,
"default sort by analytics data requires " \
formulae = analytics["items"].map do |i|
f = i["formula"].split.first
next if f.include?("/")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment