ⓔ Fixing homebrew after upgrade OS X to El Capitan

Homebrew is a great way to easily install all sorts of command line goodies as easily as brew install. I use it to install programs such as Pandoc (convert between several different text formats or create ebooks) or ImageMagick (manipulate images from the command line). Tonight I went to install Mosh (remote access command line client), but was greeted by a series of error messages:

/System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require': cannot load such file -- mach (LoadError)
 from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /usr/local/Library/Homebrew/extend/pathname.rb:2:in `<top (required)>'
 from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /usr/local/Library/Homebrew/global.rb:3:in `<top (required)>'
 from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /System/Library/Frameworks/Ruby.framework/Versions/2.0/usr/lib/ruby/2.0.0/rubygems/core_ext/kernel_require.rb:55:in `require'
 from /usr/local/Library/brew.rb:15:in `<main>'

Ugh! Luckily, Stack Overflow to the rescue. I completed the steps in the second answer which fixed everything for me.

Open a terminal and type:
$ sudo chown -R $(whoami):admin /usr/local 
$ cd /usr/local 
$ git reset --hard 
$ git clean -df
$ brew update

Hope that helps!

Start the discussion at discuss.eduk8.me