From 90e9d177894f76b5f5081d3be2a92245b2aafeda Mon Sep 17 00:00:00 2001 From: Bo Anderson Date: Wed, 17 Feb 2021 17:38:16 +0000 Subject: [PATCH] formulary: remove consts if loading failed --- Library/Homebrew/formulary.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index 3540949ab0..52734a8d0c 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -60,6 +60,7 @@ module Formulary mod.const_set(:BUILD_FLAGS, flags) mod.module_eval(contents, path) rescue NameError, ArgumentError, ScriptError, MethodDeprecatedError => e + remove_const(namespace) raise FormulaUnreadableError.new(name, e) end class_name = class_s(name) @@ -71,6 +72,7 @@ module Formulary .map { |const_name| mod.const_get(const_name) } .select { |const| const.is_a?(Class) } new_exception = FormulaClassUnavailableError.new(name, path, class_name, class_list) + remove_const(namespace) raise new_exception, "", e.backtrace end end