Gradle home cannot be found on Mac

Solution 1:

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

Solution 2:

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.

Solution 3:

On Mojave (v10.14), Gradle v5.4, I had to append libexec after Gradle version for IntelliJ to work.

/usr/local/Cellar/gradle/5.4/libexec

Solution 4:

I've gradle installed When using homebrew, below one failed with me, and kept telling undefined:

/usr/local/Cellar/gradle/<version>

The below symlink worked perfectly, and solved my issue:

/usr/local/opt/gradle/libexec