From b4e5401e660ac1962a88b151f511a0eef9cee44c Mon Sep 17 00:00:00 2001 From: Jack Nagel Date: Sat, 22 Mar 2014 11:34:26 -0500 Subject: [PATCH] Try to find install receipt when keg is unlinked This roughly matches the logic we use to determine the active keg in ARGV.kegs. --- Library/Homebrew/tab.rb | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 0c6fb79272..8016f588ad 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -51,9 +51,21 @@ class Tab < OpenStruct end def self.for_formula f - path = [f.opt_prefix, f.linked_keg].map{ |pn| pn.join(FILENAME) }.find{ |pn| pn.exist? } - # Legacy kegs may lack a receipt. If it doesn't exist, fake one - if path.nil? then self.dummy_tab(f) else self.from_file(path) end + paths = [f.opt_prefix, f.linked_keg] + + if f.rack.directory? && (dirs = f.rack.subdirs).length == 1 + paths << dirs.first + end + + paths << f.prefix + + path = paths.map { |pn| pn.join(FILENAME) }.find(&:file?) + + if path + from_file(path) + else + dummy_tab(f) + end end def self.dummy_tab f=nil