diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 59a374535e..35dca72acc 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -301,3 +301,13 @@ class DuplicateResourceError < ArgumentError super "Resource #{resource.inspect} is defined more than once" end end + +class BottleVersionMismatchError < RuntimeError + def initialize bottle_file, bottle_version, formula, formula_version + super <<-EOS.undent + Bottle version mismatch + Bottle: #{bottle_file} (#{bottle_version}) + Formula: #{formula.full_name} (#{formula_version}) + EOS + end +end diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index e5b79972df..f1fed506eb 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -90,6 +90,11 @@ class Formulary def get_formula(spec) formula = super formula.local_bottle_path = @bottle_filename + formula_version = formula.pkg_version + bottle_version = bottle_resolve_version(@bottle_filename) + unless formula_version == bottle_version + raise BottleVersionMismatchError.new(@bottle_filename, bottle_version, formula, formula_version) + end formula end end