This worked for me.
- Change the first line of
/usr/local/Library/brew.rb
to:#!/usr/bin/env ruby
. cd $(brew --repository)
git commit -am 'use env ruby'
.OLD_REF = $(git log | head -1 | sed 's/commit //')
git reset --hard HEAD^
git checkout $OLD_REF
brew update