build.gradle - Configure Eclipse so that System.getenv('PATH') returns the same value as from command line in macOS

341 views Asked by At

The environment:

  • macOS 10.15.7
  • Gradle 6.8.2
  • Eclipse Version: 2020-12 (4.18.0)

The problem:

I have a very simple Gradle build script that works from the command line but fails when running within Eclipse. I have boiled it down to the fact that System.getenv('PATH') returns 2 different values depending on gradle being run from command line or from eclipse I have created a very simple gradle build that only contains:

 tasks.register('debug') {
 doLast {
     println System.getenv('PATH')
 }

}

If I run the task from Eclipse, the output is:

> Task :debug
/usr/bin:/bin:/usr/sbin:/sbin

If I run the tasks from the macOS command line the output is:

> Task :debug
/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:/opt/X11/bin:~/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/opt/ImageMagick/bin:/Applications/Wireshark.app/Contents/MacOS:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin

It is clear that Eclipse somehow does not have access to the same PATH as my command line.

So my questions are:

  1. Can I force Eclipse to have access to the same PATH environment variable as my command line
  2. Can I configure Eclipse to add custom entries to the PATH environment variable
  3. Can I configure my Gradle run configuration in Eclipse to add custom entries to the PATH environment variable
  4. Can I configure Gradle, in general, to add custom entries to the PATH environment variable

Thanks

0

There are 0 answers