diff --git a/Library/Homebrew/cask/dsl/depends_on.rb b/Library/Homebrew/cask/dsl/depends_on.rb
index b5aa5ff7391d3fbc96ae395922d9bdbba787ee43..257ff397838651d6df819375d86efce1d7e5f140 100644
--- a/Library/Homebrew/cask/dsl/depends_on.rb
+++ b/Library/Homebrew/cask/dsl/depends_on.rb
@@ -1,5 +1,7 @@
 # frozen_string_literal: true
 
+require "requirements/macos_requirement"
+
 module Cask
   class DSL
     class DependsOn < DelegateClass(Hash)
@@ -58,7 +60,7 @@ module Cask
           else
             MacOSRequirement.new([args.first], comparator: "==")
           end
-        rescue
+        rescue MacOSVersionError
           raise "invalid 'depends_on macos' value: #{args.first.inspect}"
         end
       end
diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb
index f0b8b5505950ecd01f192ef8d6c10301547b193b..7a16ac59b761c695ba216d6a70dc31e99eadbefb 100644
--- a/Library/Homebrew/global.rb
+++ b/Library/Homebrew/global.rb
@@ -42,6 +42,7 @@ require "os"
 require "context"
 require "extend/pathname"
 require "extend/predicable"
+require "extend/module"
 require "cli/args"
 require "messages"
 
@@ -121,7 +122,6 @@ end.compact.freeze
 
 require "set"
 
-require "extend/module"
 require "extend/string"
 require "active_support/core_ext/object/blank"
 require "active_support/core_ext/hash/deep_merge"