diff --git a/Library/.rubocop.yml b/Library/.rubocop.yml index a1a78aa10c428..5d41d75b2ce93 100644 --- a/Library/.rubocop.yml +++ b/Library/.rubocop.yml @@ -279,7 +279,6 @@ Sorbet/StrictSigil: Sorbet/TrueSigil: Enabled: true Exclude: - - "Homebrew/standalone/init.rb" # loaded before sorbet-runtime - "Taps/**/*" - "/**/{Formula,Casks}/**/*.rb" - "**/{Formula,Casks}/**/*.rb" diff --git a/Library/Homebrew/standalone/init.rb b/Library/Homebrew/standalone/init.rb index fabac4124ff2d..2e72ae1db93af 100644 --- a/Library/Homebrew/standalone/init.rb +++ b/Library/Homebrew/standalone/init.rb @@ -1,4 +1,4 @@ -# typed: false +# typed: true # frozen_string_literal: true # This file is included before any other files. It intentionally has typing disabled and has minimal use of `require`. @@ -9,6 +9,8 @@ true else ruby_major, ruby_minor, = RUBY_VERSION.split(".").map(&:to_i) + raise "Could not parse Ruby requirements" if !ruby_major || !ruby_minor || !required_ruby_major + if ruby_major < required_ruby_major || (ruby_major == required_ruby_major && ruby_minor < required_ruby_minor) raise "Homebrew must be run under Ruby #{required_ruby_major}.#{required_ruby_minor}! " \ "You're running #{RUBY_VERSION}." @@ -25,7 +27,8 @@ $LOAD_PATH.reject! { |path| path.start_with?(RbConfig::CONFIG["sitedir"]) } require "pathname" -HOMEBREW_LIBRARY_PATH = Pathname(__dir__).parent.realpath.freeze +dir = __dir__ || raise("__dir__ is not defined") +HOMEBREW_LIBRARY_PATH = Pathname(dir).parent.realpath.freeze require_relative "../utils/gems" Homebrew.setup_gem_environment!(setup_path: false)