In my case a workaround of setting export HOMEBREW_NO_INSTALL_FROM_API=1 before installation helped.
export HOMEBREW_NO_INSTALL_FROM_API=1
Source and discussion: brew issue #14516.