If you are getting the following error while installing from brew then this post might help you:
$ sudo brew install gradle
Error: uninitialized constant Superenv::HOMEBREW_ENV_PATH
Please report this bug:
https://git.io/brew-troubleshooting
/usr/local/Library/Homebrew/extend/os/mac/extend/ENV/super.rb:6:in `bin'
/usr/local/Library/Homebrew/extend/ENV.rb:7:in `superenv?'
/usr/local/Library/Homebrew/extend/ENV.rb:12:in `activate_extensions!'
/usr/local/Library/Homebrew/build.rb:80:in `install'
/usr/local/Library/Homebrew/build.rb:179:in `<main>'
For resolving this issue follow these steps :
=> Make brew executable own by root
$ sudo chown root /usr/local/bin/brew
=> Now update brew
$ sudo update brew
=> Now install what you were installing, in my case it was gradle
$ sudo brew install gradle
==> Downloading https://downloads.gradle.org/distributions/gradle-2.14.1-bin.zip
######################################################################## 100.0%
🍺 /usr/local/Cellar/gradle/2.14.1: 171 files, 47.4M, built in 47 seconds
--
All the best!