I am running Gradle script. At the beginning I print PATH environment variable:
println System.getenv( 'PATH' )
The output is:
/usr/bin:/bin:/usr/sbin:/sbin
But the real PATH environment variable is (printed from terminal):
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sh........
Question is, why that PATH env variable do not math in Gradle script and in terminal?
Thing is, that I am building Android, which use Gradle as build system. And I have c++ code, which is build by CMake. And in CMake i run some python scripts, which executes some external commands. But when Gradle changes PATH variable, those commands are not found and I am getting an error. It is not an option to use full path, when executing those commands, like:
/usr/local/bin/my_mega_command
When I run CMake or python script directly, then everything works as expected.
Android Studio does not pass its environment down to the Gradle daemon that it spawns. Usually, we see this in the form of missing custom environment variables, but apparently it affects PATH
changes as well.