Gradle home cannot be found on Mac

You can use command:

brew info gradle

As the result you will have something like this:

gradle: stable 4.0.1
Build system based on the Groovy language
https://www.gradle.org/
/usr/local/Cellar/gradle/3.4 (181 files, 74.5MB) *
  Built from source on 2017-02-24 at 15:01:34
From: https://github.com/Homebrew/homebrew-core/blob/master/Formula/gradle.rb
==> Requirements
Required: java >= 1.7 ✔
==> Options
--with-all
    Installs Javadoc, examples, and source in addition to the binaries

Here, on the line 4 you can see the home path : /usr/local/Cellar/gradle/3.4


You can retrieve the path for GRADLE_HOME automatically using the following snippet in your .bashrc or .zshrc:

export GRADLE_HOME=$(brew info gradle | grep /usr/local/Cellar/gradle | awk '{print $1}')

This is handy when the path to Gradle's home changes, when Gradle is updated.