Fix conflicting symlink advice

Closes Homebrew/homebrew#27899.
This commit is contained in:
Jack Nagel 2014-03-27 09:35:10 -05:00
parent 714bfee8d9
commit f6b5c83482

View File

@ -298,23 +298,22 @@ class Pathname
# NOTE only system ln -s will create RELATIVE symlinks # NOTE only system ln -s will create RELATIVE symlinks
quiet_system 'ln', '-s', src.relative_path_from(self.dirname), self.basename quiet_system 'ln', '-s', src.relative_path_from(self.dirname), self.basename
if not $?.success? if not $?.success?
if self.exist? if symlink? && exist? || symlink?
raise <<-EOS.undent raise <<-EOS.undent
Could not symlink file: #{src.expand_path} 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: To force the link and overwrite all other conflicting files, do:
brew link --overwrite formula_name brew link --overwrite formula_name
To list all files that would be deleted: To list all files that would be deleted:
brew link --overwrite --dry-run formula_name brew link --overwrite --dry-run formula_name
EOS EOS
# #exist? will return false for symlinks whose target doesn't exist elsif exist?
elsif self.symlink?
raise <<-EOS.undent raise <<-EOS.undent
Could not symlink file: #{src.expand_path} Could not symlink file: #{src.expand_path}
Target #{self} already exists as a symlink to #{readlink}. Target #{self} already exists. You may need to delete it.
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: To force the link and overwrite all other conflicting files, do:
brew link --overwrite formula_name brew link --overwrite formula_name