Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Keg#unlink: check file comes from the right keg

For real this time.

This makes sure that files won't be unlinked if they resolve into 
other kegs. For example: if fish and fishfish are both installed, 
with fishfish linked and fish unlinked, `brew unlink fish` would 
unlink some files that resolve into fishfish's keg.
  • Loading branch information...
commit b11de180536d537f5fcef24aa983b56948c253d7 1 parent 867f1dd
@mistydemeo mistydemeo authored
Showing with 8 additions and 1 deletion.
  1. +8 −1 Library/Homebrew/keg.rb
9 Library/Homebrew/keg.rb
@@ -34,7 +34,12 @@ def unlink
src.find do |src|
next if src == self
- next unless dst.symlink?
+ # check whether the file to be unlinked is from the current keg first
+ if !dst.symlink? || !dst.exist? || src != dst.resolved_path
+ next
+ end
dst.uninstall_info if dst.to_s =~ INFOFILE_RX and ENV['HOMEBREW_KEEP_INFO']
@@ -79,6 +84,8 @@ def basename
def link mode=nil
raise "Cannot link #{fname}\nAnother version is already linked: #{linked_keg_record.realpath}" if
+ # these are used by the ObserverPathnameExtension to count the number
+ # of files and directories linked
Please sign in to comment.
Something went wrong with that request. Please try again.