diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index f31e4a291bcaf..8527d08b96d48 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -247,9 +247,7 @@ def self.formula_metadata_lines(formula) metadata << pinned end - if !formula.any_version_installed? && - formula_installs_from_source?(formula) && - formula.requirements.none? { |requirement| requirement_for_other_os?(requirement) } + if !formula.any_version_installed? && formula_installs_from_source?(formula) metadata << "Installs from source: yes" end metadata @@ -271,6 +269,7 @@ def self.pin_path_mtime(pin_path) sig { params(formula: T.untyped).returns(T::Boolean) } def self.formula_installs_from_source?(formula) + return false if formula.requirements.any? { |requirement| requirement_for_other_os?(requirement) } return true if formula.stable.blank? && formula.head.present? return false if formula.stable.blank? @@ -313,8 +312,7 @@ def self.collect_cask_dependency_names(cask, formula_dependencies, cask_dependen end end - private_class_method :formula_metadata_lines, :formatted_time, :pin_path_mtime, - :formula_installs_from_source? + private_class_method :formula_metadata_lines, :formatted_time, :pin_path_mtime sig { params(quiet: T::Boolean).void } def print_info(quiet: false) @@ -559,12 +557,10 @@ def info_formula(formula, shadowed_by: nil) else [].freeze end + built_from_source = kegs.any? { |keg| !keg.tab.poured_from_bottle } + installs_from_source = !installed && self.class.formula_installs_from_source?(formula) dependency_lines = %w[build required recommended optional].filter_map do |type| - next if type == "build" && - (kegs.all? { |keg| keg.tab.poured_from_bottle } || - (kegs.empty? && - (formula.requirements.any? { |requirement| self.class.requirement_for_other_os?(requirement) } || - (stable.present? ? stable.bottled? && formula.pour_bottle? : formula.head.blank?)))) + next if type == "build" && !built_from_source && !installs_from_source deps = formula.deps.public_send(type).uniq next if deps.empty? diff --git a/Library/Homebrew/test/cmd/info_spec.rb b/Library/Homebrew/test/cmd/info_spec.rb index 9cecdd8c56249..5510bfaee5fd6 100644 --- a/Library/Homebrew/test/cmd/info_spec.rb +++ b/Library/Homebrew/test/cmd/info_spec.rb @@ -296,6 +296,19 @@ def installed_info_cask .and not_to_output.to_stderr end + it "shows build dependencies for an uninstalled formula without a bottle" do + info = described_class.new([]) + formula = formula("testball") do + T.bind(self, T.class_of(Formula)) + url "https://brew.sh/testball-0.1.tar.gz" + depends_on "builddep" => :build + end + allow(info).to receive(:github_info).with(formula).and_return("https://example.com/testball.rb") + + expect { info.info_formula(formula) } + .to output(/Build \(1\): builddep/).to_stdout + end + it "shows a conflict by its resolved full name" do info = described_class.new([]) formula = formula("testball") do