Homebrew had build errors

Building Homebrew returns an error with the message below. I’ve tried Pkg.rm(“Homebrew”), deleting the folder .julia/v0.5/Homebrew, deleting the .julia/.cache/Homebrew and just installing Pkg.add(“Homebrew”), following Howmebrew update to v"0.5.4" gives error on both 0.5 and 0.6 - #4 by Evizero
which leads to the same error. I am using OS X 10.12.6


julia> Pkg.build("Homebrew")
INFO: Building Homebrew
Already up-to-date.
Error: git: /Users/hanrong/.julia/v0.5/Homebrew/deps/usr/Library/Taps/homebrew/homebrew-core/Formula/git.rb:190: syntax error, unexpected $undefined, expecting keyword_end
      \thelper = osxkeychain
       ^
==============================[ ERROR: Homebrew ]===============================

LoadError: ArgumentError: `brew info` failed for String["git"]!
while loading /Users/hanrong/.julia/v0.5/Homebrew/deps/build.jl, in expression starting on line 2

================================================================================

================================[ BUILD ERRORS ]================================

WARNING: Homebrew had build errors.

 - packages with build errors remain installed in /Users/hanrong/.julia/v0.5
 - build the package(s) and all dependencies with `Pkg.build("Homebrew")`
 - build a single package by running its `deps/build.jl` script

================================================================================

See https://github.com/JuliaPackaging/Homebrew.jl/issues/207.