After setting the environment variables for a user on a new Mac OS X machine (see post from 12 Oct 2018), I was surprised to see that Eclipse was unaffected by my changes to PATH.
Some details: in my scenario, the development project uses Maven for its builds, but one step runs scripts in a bin folder.
That folder has been added to my PATH. They run fine from the terminal, but from Eclipse the script steps always fail with an error something like "Cannot run xyz - No such file or directory".
The reason turns out to be: the PATH changes are made at the level of my user profile, but the Eclipse app does not refer to my individual user profile (when launched through the Finder or icon tray).
A Google search turns up lots of suggested solutions. There are so many because the approach has changed over the years, and people have different thresholds of what solutions they are willing to use, how much mucking they are comfortable with or allowed to do by their organization.
After researching and experimenting, I recommend modifying the info.plist file in the Eclipse.app. Like all solutions, it has pros and cons.
Here is how to use the Eclipse info.plist file for environment variable changes:
Some details: in my scenario, the development project uses Maven for its builds, but one step runs scripts in a bin folder.
That folder has been added to my PATH. They run fine from the terminal, but from Eclipse the script steps always fail with an error something like "Cannot run xyz - No such file or directory".
The reason turns out to be: the PATH changes are made at the level of my user profile, but the Eclipse app does not refer to my individual user profile (when launched through the Finder or icon tray).
A Google search turns up lots of suggested solutions. There are so many because the approach has changed over the years, and people have different thresholds of what solutions they are willing to use, how much mucking they are comfortable with or allowed to do by their organization.
After researching and experimenting, I recommend modifying the info.plist file in the Eclipse.app. Like all solutions, it has pros and cons.
- Pro: it works! Eclipse successfully runs the scripts that it had failed to find before the change;
- Pro: it limits the impact to just Eclipse, no other global impact on other apps or users;
- Con: you may need to redo the change when Eclipse is upgraded;
- Con: you cannot use environment variable names for short-hand; you must use the full path.
Here is how to use the Eclipse info.plist file for environment variable changes:
- In an editor open the file /Applications/eclipse/Eclipse.app/Contents/info.plist (adjusting for the specific app path for your installation)
- Add a new key-dictionary pair to the existing set of key-value pairs. Enter this, again adjusting for your specific installation:
<key>LSEnvironment</key>
<dict>
<key>PATH</key>
<string>/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:Path_to_My_scripts:Any_Other_Special_App_Paths</string>
</dict> - Save the file and close
- From Terminal run the following command to register this file with Launch Services:
/System/Library/Frameworks/CoreServices.framework/Frameworks/LaunchServices.framework/Support/lsregister -v -f /Applications/eclipse/Eclipse.app