aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew
diff options
context:
space:
mode:
authorTim D. Smith2017-04-02 08:19:29 -0700
committerTim D. Smith2017-04-02 08:19:29 -0700
commitd0feae0632e29194d09a26adf961a05de760a22a (patch)
tree396a53052cc960138cb7e9debeaefb3aa6f865be /Library/Homebrew
parent51c4c84a3f39a64d4694beebd15952d2cf1ae664 (diff)
downloadbrew-d0feae0632e29194d09a26adf961a05de760a22a.tar.bz2
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.
Diffstat (limited to 'Library/Homebrew')
-rw-r--r--Library/Homebrew/keg_relocate.rb4
1 files changed, 3 insertions, 1 deletions
diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb
index 00e941ce2..0b1a1bc94 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