diff --git a/Library/Homebrew/dev-cmd/unbottled.rb b/Library/Homebrew/dev-cmd/unbottled.rb
index f258db70024ce233109fb50bc8349fb1f2bfb7d4..8ec75447c356cbf48cb220123551f77d6e30ff6e 100644
--- a/Library/Homebrew/dev-cmd/unbottled.rb
+++ b/Library/Homebrew/dev-cmd/unbottled.rb
@@ -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 " \
+              "`HOMEBREW_NO_GITHUB_API` and `HOMEBREW_NO_ANALYTICS` to be unset"
+      end
+
       formulae = analytics["items"].map do |i|
         f = i["formula"].split.first
         next if f.include?("/")