diff --git a/Library/Homebrew/dependency.rb b/Library/Homebrew/dependency.rb index 0697ba7ff3..0b6801788e 100644 --- a/Library/Homebrew/dependency.rb +++ b/Library/Homebrew/dependency.rb @@ -10,6 +10,8 @@ class Dependency DEFAULT_ENV_PROC = proc {} def initialize(name, tags = [], env_proc = DEFAULT_ENV_PROC, option_names = [name]) + raise ArgumentError, "Dependency must have a name!" unless name + @name = name @tags = tags @env_proc = env_proc diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 0ab60f1cbe..3fe006a116 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1522,7 +1522,11 @@ class Formula if read_from_tab && (keg = opt_or_installed_prefix_keg) && (tab_deps = keg.runtime_dependencies) - return tab_deps.map { |d| Dependency.new d["full_name"] }.compact + return tab_deps.map do |d| + full_name = d["full_name"] + next unless full_name + Dependency.new full_name + end.compact end declared_runtime_dependencies | undeclared_runtime_dependencies diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 31c57cfb81..6a55ff58b4 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -613,7 +613,7 @@ class FormulaInstaller # Update tab with actual runtime dependencies tab = Tab.for_keg(keg) Tab.clear_cache - tab.runtime_dependencies = + tab.runtime_dependency_objects = formula.runtime_dependencies(read_from_tab: false) tab.write diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 508611ac80..eab57183bc 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -277,6 +277,7 @@ module Formulary # * a formula URL # * a local bottle reference def self.factory(ref, spec = :stable, alias_path: nil, from: nil) + raise ArgumentError, "Formulae must have a ref!" unless ref loader_for(ref, from: from).get_formula(spec, alias_path: alias_path) end diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index e816743f51..3b20ec19b4 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -33,10 +33,7 @@ class Tab < OpenStruct "compiler" => compiler, "stdlib" => stdlib, "aliases" => formula.aliases, - "runtime_dependencies" => runtime_deps.map do |dep| - f = dep.to_formula - { "full_name" => f.full_name, "version" => f.version.to_s } - end, + "runtime_dependencies" => Tab.runtime_deps_hash(runtime_deps), "source" => { "path" => formula.specified_path.to_s, "tap" => formula.tap&.name, @@ -203,6 +200,13 @@ class Tab < OpenStruct new(attributes) end + def self.runtime_deps_hash(deps) + deps.map do |dep| + f = dep.to_formula + { "full_name" => f.full_name, "version" => f.version.to_s } + end + end + def with?(val) option_names = val.respond_to?(:option_names) ? val.option_names : [val] @@ -262,6 +266,10 @@ class Tab < OpenStruct super unless parsed_homebrew_version < "1.1.6" end + def runtime_dependency_objects=(deps) + source["runtime_dependencies"] = Tab.runtime_deps_hash(deps) + end + def cxxstdlib # Older tabs won't have these values, so provide sensible defaults lib = stdlib.to_sym if stdlib