From d0feae0632e29194d09a26adf961a05de760a22a Mon Sep 17 00:00:00 2001 From: "Tim D. Smith" Date: Sun, 2 Apr 2017 08:19:29 -0700 Subject: [PATCH] Unlink before rewriting link ln_sf does the right thing when `dest` is a symlink pointing to a file: the symlink gets overwritten with a link pointing to the new src. But when dest points to a directory, we create a new symlink inside the folder dest points to, which doesn't help us at all. --- Library/Homebrew/keg_relocate.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index 00e941ce2f..0b1a1bc94d 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -17,7 +17,9 @@ class Keg # Don't fix relative symlinks next unless link.absolute? if link.to_s.start_with?(HOMEBREW_CELLAR.to_s) || link.to_s.start_with?(HOMEBREW_PREFIX.to_s) - FileUtils.ln_sf(link.relative_path_from(file.parent), file) + new_src = link.relative_path_from(file.parent) + file.unlink + FileUtils.ln_s(new_src, file) end end end