diff --git a/Library/Homebrew/extend/os/mac/keg_relocate.rb b/Library/Homebrew/extend/os/mac/keg_relocate.rb index 89e56a6f4c..47ebe2e265 100644 --- a/Library/Homebrew/extend/os/mac/keg_relocate.rb +++ b/Library/Homebrew/extend/os/mac/keg_relocate.rb @@ -59,8 +59,6 @@ class Keg new_name = opt_name_for(bad_name) loader_name = loader_name_for(file, new_name) next if loader_name == bad_name - # TODO: Remove the line below on the next release of ruby-macho. See Homebrew/ruby-macho@e9eaa75. - next if file.rpaths(resolve_variable_references: false).include?(loader_name) change_rpath(bad_name, loader_name, file) end diff --git a/Library/Homebrew/os/mac/mach.rb b/Library/Homebrew/os/mac/mach.rb index 35776c8610..f9818d6f84 100644 --- a/Library/Homebrew/os/mac/mach.rb +++ b/Library/Homebrew/os/mac/mach.rb @@ -64,11 +64,11 @@ module MachOShim resolve_variable_name(r.path.to_s) == resolve_variable_name(rpath) end - # TODO: Add `last: true` to `options` and replace `delete_command` with `delete_rpath` - # when the PR linked below is merged and release for ruby-macho. - # https://github.com/Homebrew/ruby-macho/pull/555 - command_to_delete = candidates.last # .path.to_s (when switching to `MachOFile#delete_rpath`) - macho.delete_command(command_to_delete, options) + # Delete the last instance to avoid changing the order in which rpaths are searched. + rpath_to_delete = candidates.last.path.to_s + options[:last] = true + + macho.delete_rpath(rpath_to_delete, options) macho.write! end