From 59dc0ed6521b98265230ac76e762064cedd25bcb Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Mon, 20 Sep 2021 20:18:19 +0100 Subject: [PATCH] formula_installer: fix error if a compatible bottle was not found --- Library/Homebrew/cmd/--cache.rb | 2 +- Library/Homebrew/cmd/fetch.rb | 2 +- Library/Homebrew/formula.rb | 2 +- Library/Homebrew/formula_installer.rb | 6 ++++-- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Library/Homebrew/cmd/--cache.rb b/Library/Homebrew/cmd/--cache.rb index 0620411636..97fabff7f8 100644 --- a/Library/Homebrew/cmd/--cache.rb +++ b/Library/Homebrew/cmd/--cache.rb @@ -63,7 +63,7 @@ module Homebrew sig { params(formula: Formula, args: CLI::Args).void } def print_formula_cache(formula, args:) if fetch_bottle?(formula, args: args) - puts formula.bottle_for_tag(args.bottle_tag).cached_download + puts formula.bottle_for_tag(args.bottle_tag&.to_sym).cached_download elsif args.HEAD? puts formula.head.cached_download else diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb index 658746ce62..4d68457bde 100644 --- a/Library/Homebrew/cmd/fetch.rb +++ b/Library/Homebrew/cmd/fetch.rb @@ -93,7 +93,7 @@ module Homebrew begin f.clear_cache if args.force? f.fetch_bottle_tab - fetch_formula(f.bottle_for_tag(args.bottle_tag), args: args) + fetch_formula(f.bottle_for_tag(args.bottle_tag&.to_sym), args: args) rescue Interrupt raise rescue => e diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index f977ea62dc..0e7db0cb20 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -371,7 +371,7 @@ class Formula # The Bottle object for given tag. # @private - sig { params(tag: T.nilable(String)).returns(T.nilable(Bottle)) } + sig { params(tag: T.nilable(Symbol)).returns(T.nilable(Bottle)) } def bottle_for_tag(tag = nil) Bottle.new(self, bottle_specification, tag) if bottled?(tag) end diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 61fac3b8a7..26b2019305 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -150,8 +150,10 @@ class FormulaInstaller return false end - bottle = formula.bottle - if bottle && !bottle.compatible_locations? + bottle = formula.bottle_for_tag(Utils::Bottles.tag.to_sym) + return false if bottle.nil? + + unless bottle.compatible_locations? if output_warning prefix = Pathname(bottle.cellar).parent opoo <<~EOS