diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index b6f21f2e52..d69d38b367 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -745,7 +745,7 @@ on_request: installed_on_request?, options: options) fi.finish rescue Exception => e # rubocop:disable Lint/RescueException ignore_interrupts do - tmp_keg.rename(installed_keg.to_s) if tmp_keg && !installed_keg.directory? + tmp_keg.rename(installed_keg.to_path) if tmp_keg && !installed_keg.directory? linked_keg.link(verbose: verbose?) if keg_was_linked end raise unless e.is_a? FormulaInstallationAlreadyAttemptedError diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 588b29c2e1..5233478d0d 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -130,10 +130,10 @@ module Formulary end def self.load_formula_from_api(name, flags:) - namespace = "FormulaNamespaceAPI#{Digest::MD5.hexdigest(name)}" + namespace = :"FormulaNamespaceAPI#{Digest::MD5.hexdigest(name)}" mod = Module.new - remove_const(namespace.to_sym) if const_defined?(namespace) + remove_const(namespace) if const_defined?(namespace) const_set(namespace, mod) mod.const_set(:BUILD_FLAGS, flags) @@ -491,14 +491,16 @@ module Formulary def initialize(url, from: nil) @url = url @from = from - uri_path = T.must(URI(url).path) + uri_path = URI(url).path + raise ArgumentError, "URL has no path component" unless uri_path + formula = File.basename(uri_path, ".rb") super formula, HOMEBREW_CACHE_FORMULA/File.basename(uri_path) end def load_file(flags:, ignore_errors:) if @from != :formula_installer - if (md = %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(?:/Formula)?/(?[\w+-.@]+).rb}.match(url)) + if (md = url.match(%r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(?:/Formula)?/(?[\w+-.@]+).rb})) raise UnsupportedInstallationMethod, "Installation of #{md[:name]} from a GitHub commit URL is unsupported! " \ "`brew extract #{md[:name]}` to a stable tap on GitHub instead." @@ -514,7 +516,7 @@ module Formulary curl_download url, to: path super rescue MethodDeprecatedError => e - if (match_data = %r{github.com/(?[\w-]+)/(?[\w-]+)/}.match(url)) + if (match_data = url.match(%r{github.com/(?[\w-]+)/(?[\w-]+)/})) e.issues_url = "https://github.com/#{match_data[:user]}/#{match_data[:repo]}/issues/new" end raise