diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index 2e878ceed8..d105a43d9b 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -1,7 +1,6 @@ # typed: true # frozen_string_literal: true -require "cli/named_args" require "ostruct" module Homebrew @@ -16,6 +15,8 @@ module Homebrew sig { void } def initialize + require "cli/named_args" + super() @processed_options = [] diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 73013b002f..44b8616dfa 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -9,6 +9,11 @@ require "ostruct" require "pp" require "forwardable" +require "rbconfig" + +RUBY_PATH = Pathname.new(RbConfig.ruby).freeze +RUBY_BIN = RUBY_PATH.dirname.freeze + require_relative "load_path" require "rubygems" @@ -41,26 +46,11 @@ HOMEBREW_DEFAULT_CACHE = ENV["HOMEBREW_DEFAULT_CACHE"] HOMEBREW_DEFAULT_LOGS = ENV["HOMEBREW_DEFAULT_LOGS"] HOMEBREW_DEFAULT_TEMP = ENV["HOMEBREW_DEFAULT_TEMP"] HOMEBREW_REQUIRED_RUBY_VERSION = ENV["HOMEBREW_REQUIRED_RUBY_VERSION"] -require "env_config" - -require "config" -require "os" -require "context" -require "extend/pathname" -require "extend/predicable" -require "extend/module" -require "cli/args" -require "messages" HOMEBREW_PRODUCT = ENV["HOMEBREW_PRODUCT"] HOMEBREW_VERSION = ENV["HOMEBREW_VERSION"] HOMEBREW_WWW = "https://brew.sh" -require "rbconfig" - -RUBY_PATH = Pathname.new(RbConfig.ruby).freeze -RUBY_BIN = RUBY_PATH.dirname.freeze - HOMEBREW_USER_AGENT_CURL = ENV["HOMEBREW_USER_AGENT_CURL"] HOMEBREW_USER_AGENT_RUBY = "#{ENV["HOMEBREW_USER_AGENT"]} ruby/#{RUBY_VERSION}-p#{RUBY_PATCHLEVEL}" @@ -72,8 +62,18 @@ HOMEBREW_DEFAULT_PREFIX = "/usr/local" HOMEBREW_MACOS_ARM_DEFAULT_PREFIX = "/opt/homebrew" HOMEBREW_LINUX_DEFAULT_PREFIX = "/home/linuxbrew/.linuxbrew" +HOMEBREW_PULL_API_REGEX = + %r{https://api\.github\.com/repos/([\w-]+)/([\w-]+)?/pulls/(\d+)}.freeze +HOMEBREW_PULL_OR_COMMIT_URL_REGEX = + %r[https://github\.com/([\w-]+)/([\w-]+)?/(?:pull/(\d+)|commit/[0-9a-fA-F]{4,40})].freeze +HOMEBREW_RELEASES_URL_REGEX = + %r{https://github\.com/([\w-]+)/([\w-]+)?/releases/download/(.+)}.freeze + require "fileutils" + +require "os" require "os/global" +require "messages" module Homebrew extend FileUtils @@ -111,12 +111,14 @@ module Homebrew end end -HOMEBREW_PULL_API_REGEX = - %r{https://api\.github\.com/repos/([\w-]+)/([\w-]+)?/pulls/(\d+)}.freeze -HOMEBREW_PULL_OR_COMMIT_URL_REGEX = - %r[https://github\.com/([\w-]+)/([\w-]+)?/(?:pull/(\d+)|commit/[0-9a-fA-F]{4,40})].freeze -HOMEBREW_RELEASES_URL_REGEX = - %r{https://github\.com/([\w-]+)/([\w-]+)?/releases/download/(.+)}.freeze +require "env_config" + +require "config" +require "context" +require "extend/pathname" +require "extend/predicable" +require "extend/module" +require "cli/args" require "PATH" diff --git a/Library/Homebrew/os/linux/global.rb b/Library/Homebrew/os/linux/global.rb index 891d5a24c7..c73ffa8135 100644 --- a/Library/Homebrew/os/linux/global.rb +++ b/Library/Homebrew/os/linux/global.rb @@ -1,6 +1,8 @@ # typed: false # frozen_string_literal: true +require "env_config" + # Enables experimental `patchelf.rb` write support. HOMEBREW_PATCHELF_RB_WRITE = ( ENV["HOMEBREW_NO_PATCHELF_RB_WRITE"].blank? && @@ -9,7 +11,7 @@ HOMEBREW_PATCHELF_RB_WRITE = ( ).freeze module Homebrew - DEFAULT_PREFIX ||= if Homebrew::EnvConfig.force_homebrew_on_linux? + DEFAULT_PREFIX ||= if EnvConfig.force_homebrew_on_linux? HOMEBREW_DEFAULT_PREFIX else HOMEBREW_LINUX_DEFAULT_PREFIX diff --git a/Library/Homebrew/tap_constants.rb b/Library/Homebrew/tap_constants.rb index b9edb7afeb..10e167b2a2 100644 --- a/Library/Homebrew/tap_constants.rb +++ b/Library/Homebrew/tap_constants.rb @@ -1,6 +1,8 @@ # typed: true # frozen_string_literal: true +require "config" + # Match taps' formulae, e.g. `someuser/sometap/someformula` HOMEBREW_TAP_FORMULA_REGEX = %r{^([\w-]+)/([\w-]+)/([\w+-.@]+)$}.freeze # Match taps' casks, e.g. `someuser/sometap/somecask` diff --git a/Library/Homebrew/utils/tty.rb b/Library/Homebrew/utils/tty.rb index 01ebc1b214..ddb7da3824 100644 --- a/Library/Homebrew/utils/tty.rb +++ b/Library/Homebrew/utils/tty.rb @@ -1,6 +1,8 @@ # typed: true # frozen_string_literal: true +require "env_config" + # Various helper functions for interacting with TTYs. # # @api private