diff --git a/Library/Homebrew/cask/cmd/--cache.rb b/Library/Homebrew/cask/cmd/--cache.rb index 54aebf6c98762d42dfb29d6628f04695ec4d409c..310c79d84e9f4ccf0495759de48d76934a77b609 100644 --- a/Library/Homebrew/cask/cmd/--cache.rb +++ b/Library/Homebrew/cask/cmd/--cache.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "cask/download" - module Cask class Cmd class Cache < AbstractCommand @@ -24,6 +22,8 @@ module Cask end def self.cached_location(cask) + require "cask/download" + Download.new(cask).downloader.cached_location end end diff --git a/Library/Homebrew/cask/cmd/audit.rb b/Library/Homebrew/cask/cmd/audit.rb index d03858c9a3f6a97dce2cd5cdef373f0519a8d268..ee457e9f76a2a0e8ddf97d9a14b3fc1843a9534e 100644 --- a/Library/Homebrew/cask/cmd/audit.rb +++ b/Library/Homebrew/cask/cmd/audit.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -require "cli/parser" -require "cask/auditor" - module Cask class Cmd class Audit < AbstractCommand @@ -35,6 +32,8 @@ module Cask end def run + require "cask/auditor" + Homebrew.auditing = true strict = args.new_cask? || args.strict? online = args.new_cask? || args.online? diff --git a/Library/Homebrew/cask/cmd/doctor.rb b/Library/Homebrew/cask/cmd/doctor.rb index 9feb0e111937b7b337f66cf83c078a05289573da..c05248344551a1493c3e2c548c8f2a6071d52791 100644 --- a/Library/Homebrew/cask/cmd/doctor.rb +++ b/Library/Homebrew/cask/cmd/doctor.rb @@ -1,8 +1,5 @@ # frozen_string_literal: true -require "system_config" -require "diagnostic" - module Cask class Cmd class Doctor < AbstractCommand @@ -15,6 +12,8 @@ module Cask end def run + require "diagnostic" + success = true checks = Homebrew::Diagnostic::Checks.new(verbose: true) diff --git a/Library/Homebrew/cask/cmd/fetch.rb b/Library/Homebrew/cask/cmd/fetch.rb index 4715087a957a9a084f4f9e7e7f3c3d579b119e72..141ae73e765d0af6d08f907a23560bc6a92f6249 100644 --- a/Library/Homebrew/cask/cmd/fetch.rb +++ b/Library/Homebrew/cask/cmd/fetch.rb @@ -1,7 +1,5 @@ # frozen_string_literal: true -require "cask/download" - module Cask class Cmd class Fetch < AbstractCommand @@ -21,6 +19,9 @@ module Cask end def run + require "cask/download" + require "cask/installer" + options = { force: args.force?, quarantine: args.quarantine?, diff --git a/Library/Homebrew/cask/cmd/info.rb b/Library/Homebrew/cask/cmd/info.rb index bcb56348cb31ca26150b4a9303d0401c03872573..a52a40464b566057e0a427b0a81cd24ca19669bb 100644 --- a/Library/Homebrew/cask/cmd/info.rb +++ b/Library/Homebrew/cask/cmd/info.rb @@ -1,7 +1,6 @@ # frozen_string_literal: true require "json" -require "cask/installer" module Cask class Cmd @@ -34,6 +33,8 @@ module Cask end def self.get_info(cask) + require "cask/installer" + output = +"#{title_info(cask)}\n" output << "#{Formatter.url(cask.homepage)}\n" if cask.homepage output << installation_info(cask) diff --git a/Library/Homebrew/cask/cmd/install.rb b/Library/Homebrew/cask/cmd/install.rb index da74e0958dcb80bc4c6d86f4d826289e74e9721b..55b8f77ee8bc8a9c92ed5fd19d8444e8dd1f8cb3 100644 --- a/Library/Homebrew/cask/cmd/install.rb +++ b/Library/Homebrew/cask/cmd/install.rb @@ -23,6 +23,8 @@ module Cask end def run + require "cask/installer" + options = { binaries: args.binaries?, verbose: args.verbose?, diff --git a/Library/Homebrew/cask/cmd/internal_stanza.rb b/Library/Homebrew/cask/cmd/internal_stanza.rb index 5db74bd0126ceff10f8bd1cf4edfbdf5ec65da83..41f91ebf5c4f6f4545417f6f4d9e45beae72eab7 100644 --- a/Library/Homebrew/cask/cmd/internal_stanza.rb +++ b/Library/Homebrew/cask/cmd/internal_stanza.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "cask/dsl" + module Cask class Cmd class InternalStanza < AbstractInternalCommand diff --git a/Library/Homebrew/cask/cmd/reinstall.rb b/Library/Homebrew/cask/cmd/reinstall.rb index 75edc85813216b2fa9296102736e233b868e0d99..2264b246be7638cd10b91607ee4d9c36c51fce13 100644 --- a/Library/Homebrew/cask/cmd/reinstall.rb +++ b/Library/Homebrew/cask/cmd/reinstall.rb @@ -28,6 +28,7 @@ module Cask require_sha: nil, quarantine: nil ) + require "cask/installer" options = { binaries: binaries, diff --git a/Library/Homebrew/cask/cmd/uninstall.rb b/Library/Homebrew/cask/cmd/uninstall.rb index cde416c65d396d2932ea45037f333c55b9f35400..1acb9fb1096d544d91826631532fbf629c89234a 100644 --- a/Library/Homebrew/cask/cmd/uninstall.rb +++ b/Library/Homebrew/cask/cmd/uninstall.rb @@ -29,6 +29,8 @@ module Cask end def self.uninstall_casks(*casks, binaries: nil, force: false, verbose: false) + require "cask/installer" + options = { binaries: binaries, force: force, diff --git a/Library/Homebrew/cask/cmd/upgrade.rb b/Library/Homebrew/cask/cmd/upgrade.rb index 6edf182451a3383874000986e8a83826fe2f8f53..2562cdfab0a7100394fd3b69ec0ac370d037e6bb 100644 --- a/Library/Homebrew/cask/cmd/upgrade.rb +++ b/Library/Homebrew/cask/cmd/upgrade.rb @@ -100,6 +100,8 @@ module Cask old_cask, new_cask, binaries:, force:, quarantine:, require_sha:, skip_cask_deps:, verbose: ) + require "cask/installer" + odebug "Started upgrade process for Cask #{old_cask}" old_config = old_cask.config diff --git a/Library/Homebrew/cli/named_args.rb b/Library/Homebrew/cli/named_args.rb index 414595b2d68a8699ca1ddb1d4b95e1e301c007a1..2597f4ba51445dd483929975bdea35ea4f044224 100644 --- a/Library/Homebrew/cli/named_args.rb +++ b/Library/Homebrew/cli/named_args.rb @@ -1,6 +1,8 @@ # frozen_string_literal: true +require "cask/cask_loader" require "delegate" +require "formulary" module Homebrew module CLI @@ -133,6 +135,8 @@ module Homebrew def resolve_keg(name) raise UsageError if name.blank? + require "keg" + rack = Formulary.to_rack(name.downcase) dirs = rack.directory? ? rack.subdirs : [] diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index 1f6ab8a08d2b1e7f0857692c385e250d0b79b41a..6b86cff43a7dcfbc7243b8a06e5754e668febf64 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -4,7 +4,6 @@ require "env_config" require "cli/args" require "optparse" require "set" -require "formula" require "utils/tty" COMMAND_DESC_WIDTH = 80 diff --git a/Library/Homebrew/dev-cmd/extract.rb b/Library/Homebrew/dev-cmd/extract.rb index 9eb432a17c192d57bcde4ba0633acc0f60996681..8ac3d0453070ead398195c16ceea45160e231700 100644 --- a/Library/Homebrew/dev-cmd/extract.rb +++ b/Library/Homebrew/dev-cmd/extract.rb @@ -3,6 +3,7 @@ require "cli/parser" require "utils/git" require "formulary" +require "software_spec" require "tap" def with_monkey_patch diff --git a/Library/Homebrew/extend/os/linux/extend/ENV/super.rb b/Library/Homebrew/extend/os/linux/extend/ENV/super.rb index 965d7a2ce5a85471cdc190ef37e0142367404788..b5ba7e450eceee237ea76fa0d88fd80df81d000d 100644 --- a/Library/Homebrew/extend/os/linux/extend/ENV/super.rb +++ b/Library/Homebrew/extend/os/linux/extend/ENV/super.rb @@ -17,7 +17,7 @@ module Superenv def homebrew_extra_paths paths = [] paths += %w[binutils make].map do |f| - bin = Formula[f].opt_bin + bin = Formulary.factory(f).opt_bin bin if bin.directory? rescue FormulaUnavailableError nil diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index ce3d098cf920fda92e02cbf7cf5c85342b0321a0..c9e147a91ea69b8999ae3204e595fc427b893cd3 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -2,6 +2,7 @@ require "digest/md5" require "extend/cachable" +require "tab" # The Formulary is responsible for creating instances of {Formula}. # It is not meant to be used directly from formulae. @@ -30,6 +31,8 @@ module Formulary def self.load_formula(name, path, contents, namespace, flags:) raise "Formula loading disabled by HOMEBREW_DISABLE_LOAD_FORMULA!" if Homebrew::EnvConfig.disable_load_formula? + require "formula" + mod = Module.new const_set(namespace, mod) diff --git a/Library/Homebrew/global.rb b/Library/Homebrew/global.rb index 30d0eacb9479585ff4134558a63b5d03d4cc1431..f0b8b5505950ecd01f192ef8d6c10301547b193b 100644 --- a/Library/Homebrew/global.rb +++ b/Library/Homebrew/global.rb @@ -6,6 +6,7 @@ require "json/add/exception" require "pathname" require "ostruct" require "pp" +require "forwardable" require_relative "load_path" @@ -38,6 +39,9 @@ require "env_config" require "config" require "os" +require "context" +require "extend/pathname" +require "extend/predicable" require "cli/args" require "messages" @@ -106,7 +110,6 @@ HOMEBREW_PULL_API_REGEX = HOMEBREW_PULL_OR_COMMIT_URL_REGEX = %r[https://github\.com/([\w-]+)/([\w-]+)?/(?:pull/(\d+)|commit/[0-9a-fA-F]{4,40})].freeze -require "forwardable" require "PATH" ENV["HOMEBREW_PATH"] ||= ENV["PATH"] @@ -118,11 +121,7 @@ end.compact.freeze require "set" -require "context" -require "extend/pathname" - require "extend/module" -require "extend/predicable" require "extend/string" require "active_support/core_ext/object/blank" require "active_support/core_ext/hash/deep_merge" diff --git a/Library/Homebrew/tap.rb b/Library/Homebrew/tap.rb index 1138cf6149da96c102380ec640bd8cbf7fe0c449..d83f09891c62da13e8b85269a5510c0a72642183 100644 --- a/Library/Homebrew/tap.rb +++ b/Library/Homebrew/tap.rb @@ -2,7 +2,6 @@ require "commands" require "extend/cachable" -require "readall" require "description_cache_store" # A {Tap} is used to extend the formulae provided by Homebrew core. @@ -232,6 +231,7 @@ class Tap # @param quiet [Boolean] If set, suppress all output. def install(full_clone: true, quiet: false, clone_target: nil, force_auto_update: nil) require "descriptions" + require "readall" if official? && DEPRECATED_OFFICIAL_TAPS.include?(repo) odie "#{name} was deprecated. This tap is now empty and all its contents were either deleted or migrated." diff --git a/Library/Homebrew/test/cask/cmd/audit_spec.rb b/Library/Homebrew/test/cask/cmd/audit_spec.rb index 96e295f618cf226dd77b590d912a6a003d3e9726..587734b0a60df6e5b64220bcf31088ae3c00005a 100644 --- a/Library/Homebrew/test/cask/cmd/audit_spec.rb +++ b/Library/Homebrew/test/cask/cmd/audit_spec.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require_relative "shared_examples/invalid_option" +require "cask/auditor" describe Cask::Cmd::Audit, :cask do let(:cask) { Cask::Cask.new("cask") } diff --git a/Library/Homebrew/test/dev-cmd/extract_spec.rb b/Library/Homebrew/test/dev-cmd/extract_spec.rb index a34d6f844e94f243a274973dc8054a4af4db038d..c12c4eb06a319fc2685a89a1ccaf4f4ffa687919 100644 --- a/Library/Homebrew/test/dev-cmd/extract_spec.rb +++ b/Library/Homebrew/test/dev-cmd/extract_spec.rb @@ -27,23 +27,32 @@ describe "brew extract", :integration_test do end it "retrieves the most recent version of formula" do + path = target[:path]/"Formula/testball@0.2.rb" expect { brew "extract", "testball", target[:name] } - .to be_a_success - expect(target[:path]/"Formula/testball@0.2.rb").to exist - expect(Formulary.factory(target[:path]/"Formula/testball@0.2.rb").version).to be == "0.2" + .to output(/^#{path}$/).to_stdout + .and not_to_output.to_stderr + .and be_a_success + expect(path).to exist + expect(Formulary.factory(path).version).to be == "0.2" end it "retrieves the specified version of formula" do + path = target[:path]/"Formula/testball@0.1.rb" expect { brew "extract", "testball", target[:name], "--version=0.1" } - .to be_a_success - expect(target[:path]/"Formula/testball@0.1.rb").to exist - expect(Formulary.factory(target[:path]/"Formula/testball@0.1.rb").version).to be == "0.1" + .to output(/^#{path}$/).to_stdout + .and not_to_output.to_stderr + .and be_a_success + expect(path).to exist + expect(Formulary.factory(path).version).to be == "0.1" end it "retrieves the compatible version of formula" do - expect { brew "extract", "testball", target[:name], "--version=0", "--debug" } - .to be_a_success - expect(target[:path]/"Formula/testball@0.rb").to exist - expect(Formulary.factory(target[:path]/"Formula/testball@0.rb").version).to be == "0.2" + path = target[:path]/"Formula/testball@0.rb" + expect { brew "extract", "testball", target[:name], "--version=0" } + .to output(/^#{path}$/).to_stdout + .and not_to_output.to_stderr + .and be_a_success + expect(path).to exist + expect(Formulary.factory(path).version).to be == "0.2" end end diff --git a/Library/Homebrew/test/support/helper/cask/install_helper.rb b/Library/Homebrew/test/support/helper/cask/install_helper.rb index 25ba7ea17a71b78349062e481bf5197536e0684a..19ef9594e0c77f5b99f77d52a6a4e095d9a593b0 100644 --- a/Library/Homebrew/test/support/helper/cask/install_helper.rb +++ b/Library/Homebrew/test/support/helper/cask/install_helper.rb @@ -1,5 +1,7 @@ # frozen_string_literal: true +require "cask/installer" + module InstallHelper module_function diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb b/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb index 80328827a90329d4a79979649618a50d77aa77f3..87c9517b6cbab92c1c0645b925c214956f775ed9 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/homebrew_cask.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true require "cask/config" +require "cask/cache" require "test/support/helper/cask/fake_system_command" require "test/support/helper/cask/install_helper"