Search code examples
intellij-ideagradle

Get null use System.getenv() in gradle


def CATALINA_HOME = System.getenv("CATALINA_HOME")
task t << {
    println CATALINA_HOME
}

CATALINA_HOME is null when I run with idea (double click t from Gradle Project panel), but when gradle t is executed in terminal I get a correct path. It seem this is only happen in OSX (my version is 10.11.14 El Capitan).


Solution

  • IntelliJ IDEA has problems with recognizing environment variables on OS X (not sure if on other systems as well). Please have a look at this post - it should solve the problem (some time ago I had similar issue and found it very useful).

    Since the linked page no longer exists you can find it in the archive here. Thanks @AlexeyStepanov!