From 06fe347de97975dc01e726f87bf07a56a6fb713e Mon Sep 17 00:00:00 2001
From: Martin Afanasjew <martin@afanasjew.de>
Date: Wed, 10 Aug 2016 17:56:46 +0200
Subject: [PATCH] os/mac/ruby_keg: improve error reporting

A failure to change a dylib ID or install name would previously cause a
rather cryptic error message, that didn't include the name of the file
that caused the failure, unless `--debug` was specified. Make sure to
output this information in all cases before re-raising the exception.
---
 Library/Homebrew/os/mac/ruby_keg.rb | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/Library/Homebrew/os/mac/ruby_keg.rb b/Library/Homebrew/os/mac/ruby_keg.rb
index f6fc334952..26babdc3d3 100644
--- a/Library/Homebrew/os/mac/ruby_keg.rb
+++ b/Library/Homebrew/os/mac/ruby_keg.rb
@@ -5,12 +5,26 @@ module RubyKeg
     @require_install_name_tool = true
     puts "Changing dylib ID of #{file}\n  from #{file.dylib_id}\n    to #{id}" if ARGV.debug?
     MachO::Tools.change_dylib_id(file, id)
+  rescue MachO::MachOError
+    onoe <<-EOS.undent
+      Failed changing dylib ID of #{file}
+        from #{file.dylib_id}
+          to #{id}
+    EOS
+    raise
   end
 
   def change_install_name(old, new, file)
     @require_install_name_tool = true
     puts "Changing install name in #{file}\n  from #{old}\n    to #{new}" if ARGV.debug?
     MachO::Tools.change_install_name(file, old, new)
+  rescue MachO::MachOError
+    onoe <<-EOS.undent
+      Failed changing install name in #{file}
+        from #{old}
+          to #{new}
+    EOS
+    raise
   end
 
   def require_install_name_tool?
-- 
GitLab