From c20809526c4f3c794de592dbde2663bb0da28451 Mon Sep 17 00:00:00 2001 From: Martin Afanasjew Date: Mon, 15 Feb 2016 17:56:47 +0100 Subject: [PATCH] os/mac/ruby_mach: don't hide actual parse errors The current approach of suppressing all output regardless of what the error is makes it very hard to debug any issues and misread but valid Mach-O files will be silently interpreted as non-Mach-O files instead. Prefer to fail if we are a Homebrew developer or running on the bot (`HOMEBREW_DEVELOPER=1`), so that problems will be noticed and fixed before the silent failure leads to hard-to-diagnose user problems. Closes Homebrew/homebrew#48817. Signed-off-by: Martin Afanasjew --- Library/Homebrew/os/mac/ruby_mach.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Library/Homebrew/os/mac/ruby_mach.rb b/Library/Homebrew/os/mac/ruby_mach.rb index 3cd0ac0b9d..adef7b6613 100644 --- a/Library/Homebrew/os/mac/ruby_mach.rb +++ b/Library/Homebrew/os/mac/ruby_mach.rb @@ -41,7 +41,15 @@ module RubyMachO end mach_data + rescue MachO::NotAMachOError + # Silently ignore errors that indicate the file is not a Mach-O binary ... + [] rescue + # ... but complain about other (parse) errors for further investigation. + if ARGV.homebrew_developer? + onoe "Failed to read Mach-O binary: #{self}" + raise + end [] end end