aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJack Nagel2014-03-27 09:35:10 -0500
committerJack Nagel2014-03-27 09:35:10 -0500
commitc1c47b56c826bda0d50f870ac67c2a5af9df5fd3 (patch)
treec5dc8e22044c2c5b82b7b600c96b40d46980a770
parent7ddb7a43416d0f0ad6501c685dd9b927ac06ea70 (diff)
downloadhomebrew-c1c47b56c826bda0d50f870ac67c2a5af9df5fd3.tar.bz2
Fix conflicting symlink advice
Closes #27899.
-rw-r--r--Library/Homebrew/extend/pathname.rb13
1 files changed, 6 insertions, 7 deletions
diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb
index c9c233144..1ec35b9cd 100644
--- a/Library/Homebrew/extend/pathname.rb
+++ b/Library/Homebrew/extend/pathname.rb
@@ -298,23 +298,22 @@ class Pathname
# NOTE only system ln -s will create RELATIVE symlinks
quiet_system 'ln', '-s', src.relative_path_from(self.dirname), self.basename
if not $?.success?
- if self.exist?
+ if symlink? && exist? || symlink?
raise <<-EOS.undent
Could not symlink file: #{src.expand_path}
- Target #{self} already exists. You may need to delete it.
+ Target #{self} already exists as a symlink to #{readlink}.
+ If this file is from another formula, you may need to
+ `brew unlink` it. Otherwise, you may want to delete it.
To force the link and overwrite all other conflicting files, do:
brew link --overwrite formula_name
To list all files that would be deleted:
brew link --overwrite --dry-run formula_name
EOS
- # #exist? will return false for symlinks whose target doesn't exist
- elsif self.symlink?
+ elsif exist?
raise <<-EOS.undent
Could not symlink file: #{src.expand_path}
- Target #{self} already exists as a symlink to #{readlink}.
- If this file is from another formula, you may need to
- `brew unlink` it. Otherwise, you may want to delete it.
+ Target #{self} already exists. You may need to delete it.
To force the link and overwrite all other conflicting files, do:
brew link --overwrite formula_name