diff --git a/Library/Homebrew/extend/os/mac/keg_relocate.rb b/Library/Homebrew/extend/os/mac/keg_relocate.rb index 5139d2494a..8fed56b88e 100644 --- a/Library/Homebrew/extend/os/mac/keg_relocate.rb +++ b/Library/Homebrew/extend/os/mac/keg_relocate.rb @@ -72,7 +72,8 @@ class Keg # If none of the install names reference RPATH(s), then we can safely # remove all RPATHs from the file. - if file.dynamically_linked_libraries.none? { |lib| lib.start_with?("@rpath") } + if ENV["HOMEBREW_RELOCATE_METAVARS"] && + file.dynamically_linked_libraries.none? { |lib| lib.start_with?("@rpath") } # Note: This could probably be made more efficient by reverse-sorting # the RPATHs by offset and calling MachOFile#delete_command # with repopulate: false. @@ -120,6 +121,7 @@ class Keg def each_install_name_for(file, &block) dylibs = file.dynamically_linked_libraries dylibs.reject! { |fn| fn =~ /^@(loader|executable)_path/ } + dylibs.reject! { |fn| fn =~ /^@rpath/ } unless ENV["HOMEBREW_RELOCATE_METAVARS"] dylibs.each(&block) end