diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index 47479d35d3..e9838640f5 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -74,13 +74,16 @@ class Keg s = first.open("rb", &:read) replacements = { - relocation.old_prefix => relocation.new_prefix, - relocation.old_cellar => relocation.new_cellar, - relocation.old_library => relocation.new_library, + relocation.old_prefix => relocation.new_prefix, + relocation.old_cellar => relocation.new_cellar, } # when HOMEBREW_PREFIX == HOMEBREW_REPOSITORY we should use HOMEBREW_PREFIX for all relocations to avoid # being unable to differentiate between them. - replacements[relocation.old_repository] = relocation.new_repository if HOMEBREW_PREFIX != HOMEBREW_REPOSITORY + if HOMEBREW_PREFIX == HOMEBREW_REPOSITORY + replacements[relocation.old_library] = relocation.new_library + else + replacements[relocation.old_repository] = relocation.new_repository + end changed = s.gsub!(Regexp.union(replacements.keys.sort_by(&:length).reverse), replacements) next unless changed