Search code examples
gradlebuild.gradlegriffon

GVM installed gradle is not recognized in Linux terminal


Recently installed gradle via gvm and $ gradle build throws the following error message.

If 'gradle' is not a typo you can use command-not-found to lookup the package that contains it, like this: cnf gradle

Obviously, class path issues, So I have tried echo $GRADLE_HOME outputs /home/karthikeyan/.gvm/gradle/current

But the actual binary is at /home/karthikeyan/.gvm/gradle/2.3/bin (exporting this to path variable,works). What if I am switching between the versions? Is there any general solution ?


Solution

  • You should always use $GRADLE_HOME which points to $HOME/.gvm/gradle/current/- so if not $GRADLE_HOME use the latter path.

    If there's a need to switch between versions use the following command:

    gvm use gradle <version>
    

    The ../current/ path is a symlink that points the version of gradle being in use. It's done in the following way to ease the usage - just add ../current path to $PATH and it's done, instead of switching the versions manually every time new version is installed.