diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index a3521d5590..bd4d1dd6da 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1981,6 +1981,9 @@ class Formula import site; site.addsitedir("#{HOMEBREW_PREFIX}/lib/python2.7/site-packages") import sys, os; sys.path = (os.environ["PYTHONPATH"].split(os.pathsep) if "PYTHONPATH" in os.environ else []) + ["#{HOMEBREW_PREFIX}/lib/python2.7/site-packages"] + sys.path PYTHON + + # Don't let bazel write to tmp directories we don't control or clean. + (home/".bazelrc").write "startup --output_user_root=#{home}/_bazel" end # Returns a list of Dependency objects that are declared in the formula. diff --git a/Library/Homebrew/mktemp.rb b/Library/Homebrew/mktemp.rb index fb1eeb5397..fbfc7ef627 100644 --- a/Library/Homebrew/mktemp.rb +++ b/Library/Homebrew/mktemp.rb @@ -62,9 +62,23 @@ class Mktemp begin Dir.chdir(tmpdir) { yield self } ensure - ignore_interrupts { rm_rf(tmpdir) } unless retain? + ignore_interrupts { chmod_rm_rf(tmpdir) } unless retain? end ensure ohai "Temporary files retained at:", @tmpdir.to_s if retain? && !@tmpdir.nil? && !@quiet end + + private + + def chmod_rm_rf(path) + if path.directory? && !path.symlink? + chmod("u+rw", path) if path.owned? # Need permissions in order to see the contents + path.children.each { |child| chmod_rm_rf(child) } + rmdir(path) + else + rm_f(path) + end + rescue + nil # Just skip this directory. + end end