mxcl/homebrew — pull request #18606 by afh (2013-03-20 12:02:44+00:00)
Title: Replace Pathname.new('~/…').expand_path with $HOME

When using brew from a shell script that is itself being
executed from another program the following error can be observed:

find HOME environment -- expanding `~/Library/Caches/Homebrew' (ArgumentError)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/pathname.rb:853:in `expand_path'
from /opt/homebrew/Library/Homebrew/global.rb:23:in `cache'
from /opt/homebrew/Library/Homebrew/global.rb:42
from /opt/homebrew/Library/brew.rb:18:in `require'
from /opt/homebrew/Library/brew.rb:18

Using ENV['HOME'] instead of tilde expansion from Pathname:expand_path
remedies this problem. For consistency all uses of Pathname.new('~/…').expand_path
have been replaced with Pathname.new("#{ENV['HOME']/…").