diff --git a/Library/Homebrew/exceptions.rb b/Library/Homebrew/exceptions.rb index 80c26335378e6..5a920bff7fc3d 100644 --- a/Library/Homebrew/exceptions.rb +++ b/Library/Homebrew/exceptions.rb @@ -548,6 +548,10 @@ def initialize(cmd, status:, output: nil) super s end + + def stderr + [*output].select { |type,| type == :stderr }.map(&:last).join + end end # Raised by {Pathname#verify_checksum} when "expected" is nil or empty. diff --git a/Library/Homebrew/extend/os/mac/unpack_strategy/zip.rb b/Library/Homebrew/extend/os/mac/unpack_strategy/zip.rb index 56b7201081c8c..f5db4587456d0 100644 --- a/Library/Homebrew/extend/os/mac/unpack_strategy/zip.rb +++ b/Library/Homebrew/extend/os/mac/unpack_strategy/zip.rb @@ -2,7 +2,16 @@ module UnpackStrategy class Zip prepend Module.new { def extract_to_dir(unpack_dir, basename:, verbose:) - result = super + result = begin + super + rescue ErrorDuringExecution => e + raise unless e.stderr.include?("End-of-central-directory signature not found.") + + system_command! "ditto", + args: ["-x", "-k", path, unpack_dir], + verbose: verbose + return + end volumes = result.stderr.chomp .split("\n")