Skip to content
This repository
Browse code

Fix issues with writable? detection in brew doctor

Closes #13689.

Signed-off-by: Max Howell <mxcl@me.com>

There are subtle distinctions between writable? and writable_real? we don't
understand precisely why we need this, but it fixes the bugs :/
commit 8aa4f9dd3bbd885350776171d3d9403d381e1a59 1 parent 0bd72cb
Brandon Black authored July 28, 2012 mxcl committed August 06, 2012
2  Library/Contributions/cmds/brew-unpack.rb
@@ -73,7 +73,7 @@ def unpack
73 73
       unpack_dir.mkpath unless unpack_dir.exist?
74 74
     end
75 75
 
76  
-    raise "Cannot write to #{unpack_dir}" unless unpack_dir.writable?
  76
+    raise "Cannot write to #{unpack_dir}" unless unpack_dir.writable_real?
77 77
 
78 78
     formulae.each do |f|
79 79
       # Create a nice name for the stage folder.
2  Library/Contributions/install_homebrew.rb
@@ -84,7 +84,7 @@ def macos_version
84 84
              share/man/man5 share/man/man6 share/man/man7 share/man/man8
85 85
              share/info share/doc share/aclocal ).
86 86
             map{ |d| "/usr/local/#{d}" }.
87  
-            select{ |d| File.directory? d and not File.writable? d }
  87
+            select{ |d| File.directory? d and not File.writable_real? d }
88 88
 chgrps = chmods.reject{ |d| File.stat(d).grpowned? }
89 89
 
90 90
 unless chmods.empty?
6  Library/Homebrew/cmd/doctor.rb
@@ -279,7 +279,7 @@ def __check_subdir_access base
279 279
 
280 280
   target.find do |d|
281 281
     next unless d.directory?
282  
-    cant_read << d unless d.writable?
  282
+    cant_read << d unless d.writable_real?
283 283
   end
284 284
 
285 285
   cant_read.sort!
@@ -300,7 +300,7 @@ def __check_subdir_access base
300 300
 def check_access_usr_local
301 301
   return unless HOMEBREW_PREFIX.to_s == '/usr/local'
302 302
 
303  
-  unless Pathname('/usr/local').writable? then <<-EOS.undent
  303
+  unless Pathname('/usr/local').writable_real? then <<-EOS.undent
304 304
     The /usr/local directory is not writable.
305 305
     Even if this directory was writable when you installed Homebrew, other
306 306
     software may change permissions on this directory. Some versions of the
@@ -322,7 +322,7 @@ def check_access_share_man
322 322
 
323 323
 def __check_folder_access base, msg
324 324
   folder = HOMEBREW_PREFIX+base
325  
-  if folder.exist? and not folder.writable?
  325
+  if folder.exist? and not folder.writable_real?
326 326
     <<-EOS.undent
327 327
       #{folder} isn't writable.
328 328
       This can happen if you "sudo make install" software that isn't managed
4  Library/Homebrew/cmd/install.rb
@@ -33,8 +33,8 @@ def check_ppc
33 33
   end
34 34
 
35 35
   def check_writable_install_location
36  
-    raise "Cannot write to #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.exist? and not HOMEBREW_CELLAR.writable?
37  
-    raise "Cannot write to #{HOMEBREW_PREFIX}" unless HOMEBREW_PREFIX.writable? or HOMEBREW_PREFIX.to_s == '/usr/local'
  36
+    raise "Cannot write to #{HOMEBREW_CELLAR}" if HOMEBREW_CELLAR.exist? and not HOMEBREW_CELLAR.writable_real?
  37
+    raise "Cannot write to #{HOMEBREW_PREFIX}" unless HOMEBREW_PREFIX.writable_real? or HOMEBREW_PREFIX.to_s == '/usr/local'
38 38
   end
39 39
 
40 40
   def check_xcode
4  Library/Homebrew/extend/pathname.rb
@@ -353,7 +353,7 @@ def make_relative_symlink src
353 353
             To list all files that would be deleted:
354 354
               brew link -n formula_name
355 355
             EOS
356  
-        elsif !dirname.writable?
  356
+        elsif !dirname.writable_real?
357 357
           raise <<-EOS.undent
358 358
             Could not symlink file: #{src.expand_path}
359 359
             #{dirname} is not writable. You should change its permissions.
@@ -375,7 +375,7 @@ def / that
375 375
 
376 376
   def ensure_writable
377 377
     saved_perms = nil
378  
-    unless writable?
  378
+    unless writable_real?
379 379
       saved_perms = stat.mode
380 380
       chmod 0644
381 381
     end
2  Library/Homebrew/global.rb
@@ -16,7 +16,7 @@ def cache
16 16
     # we do this for historic reasons, however the cache *should* be the same
17 17
     # directory whichever user is used and whatever instance of brew is executed
18 18
     home_cache = Pathname.new("~/Library/Caches/Homebrew").expand_path
19  
-    if home_cache.directory? and home_cache.writable?
  19
+    if home_cache.directory? and home_cache.writable_real?
20 20
       home_cache
21 21
     else
22 22
       root_cache = Pathname.new("/Library/Caches/Homebrew")

0 notes on commit 8aa4f9d

Please sign in to comment.
Something went wrong with that request. Please try again.