Gradle House not found on Mac

I installed gradle on MAC using terminal.

brew install gradle

Gradle has been successfully installed.

 gradle -v ------------------------------------------------------------ Gradle 3.3 ------------------------------------------------------------ Build time: 2017-01-03 15:31:04 UTC Revision: 075893a3d0798c0c1f322899b41ceca82e4e134b Groovy: 2.4.7 Ant: Apache Ant(TM) version 1.9.6 compiled on June 29 2015 JVM: 1.8.0_112 (Oracle Corporation 25.112-b16) OS: Mac OS X 10.12.3 x86_64 

but I can not find gradle home.

 echo $GRADLE_HOME [empty result] 

The first step to locating the home directory is to locate the gradle :

 which gradle /usr/local/bin/gradle 

There is an incomprehensible bash file.


Any ideas on how to detect the gradle home directory via terminal?

+31
java bash gradle macos
source share
6 answers

You can use the command:

 brew info gradle 

As a 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 line 4, you can see the home path: /usr/local/Cellar/gradle/3.4

+47
source share

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

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

This is useful when changing the path to Gradle home when updating Gradle.

+14
source share

I installed gradle. When I used homebrew, I had a crash below one, and I kept saying undefined:

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

The symbolic link below worked perfectly and solved my problem:

 /usr/local/opt/gradle/libexec 
0
source share

In Mojave (v10.14), Gradle v5.4, I had to add libexec after the Gradle version for IntelliJ to work.

 /usr/local/Cellar/gradle/5.4/libexec 
0
source share

How to install Gradle on Mac

  1. Open Terminal on Mac
  2. Check if brew is installed or not, just write brew, if it is installed, then write

brew install gradle

  1. If it is not installed, install it and write the following line in the terminal

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  1. Now Gradle will be installed
  2. Now maybe it will give an error

/Users/Desktop/project-name/platforms/android/gradlew: Command failed with exit code EACCES

  1. The next step will be

sudo chmod 777/Applications/Android\ Studio.app/Contents/gradle/gradle-4.10.1/bin/

sudo chmod 777/Users/xyz/Desktop/project-name/platforms/android/gradlew

Happy setting! Hola !! It will work

0
source share

My opinion is not enough to comment on the flick response in the previous post. If this happens on MacOS, the asterisk should be escaped as:

 brew info gradle | sed -nE 's#^(/usr/local/Cellar/gradle/[^ ]+).+\*#\1#p' 

or there will be sed: 1: "s#^(/usr/local/Cellar/g... error sed: 1: "s#^(/usr/local/Cellar/g... : RE: the operand of the repeat operator is invalid ").

-one
source share

All Articles