diff --git a/Library/Homebrew/extend/cachable.rb b/Library/Homebrew/extend/cachable.rb index 6472cca03f25d..d3d2794bc38a4 100644 --- a/Library/Homebrew/extend/cachable.rb +++ b/Library/Homebrew/extend/cachable.rb @@ -7,9 +7,10 @@ def cache @cache ||= T.let({}, T.nilable(T::Hash[T.untyped, T.untyped])) end + # NOTE: We overwrite here instead of using `Hash#clear` to handle frozen hashes. sig { void } def clear_cache - cache.clear + overwrite_cache!({}) end private diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index c479ddacdf32c..8810dc4e7be50 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -226,7 +226,7 @@ def self.load_formula_from_api(name, flags:) end if info&.key?("uses_from_macos") - bounds = info["uses_from_macos"] || {} + bounds = info["uses_from_macos"].dup || {} bounds.deep_transform_keys!(&:to_sym) bounds.deep_transform_values!(&:to_sym) diff --git a/Library/Homebrew/test/api/internal_tap_json/formula_spec.rb b/Library/Homebrew/test/api/internal_tap_json/formula_spec.rb index 2cfe78426dcb7..0b6f3c04fdf29 100644 --- a/Library/Homebrew/test/api/internal_tap_json/formula_spec.rb +++ b/Library/Homebrew/test/api/internal_tap_json/formula_spec.rb @@ -33,7 +33,7 @@ allow(Homebrew::API).to receive(:fetch_json_api_file) .with("internal/v3/homebrew-core.jws.json") - .and_return([JSON.parse(internal_tap_json), false]) + .and_return([JSON.parse(internal_tap_json, freeze: true), false]) # `Tap.tap_migration_oldnames` looks for renames in every # tap so `CoreCaskTap.tap_migrations` gets called and tries to