When I print out the path in bash, it prints this:

/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin

When I run System.out.println(System.getenv("PATH")); in Java running under Eclipse, it prints

/usr/bin:/bin:/usr/sbin:/sbin

How can I figure out why there is this discrepancy? I need to add /usr/local/bin to the PATH and make it available to Java apps under Eclipse. (note: I have made no modifications system paths, so these are the defaults set by the OS or perhaps by one or more of the applications i've installed.)

link|improve this question

71% accept rate
feedback

3 Answers

If you want to set an variable system wide on OSX you need to put it in your ~/.MacOSX/environment.plist file.

See this page on the apple website for more detail.

link|improve this answer
I think this is the right answer, anyway it worked for me. – spacemanaki Dec 3 '10 at 22:44
feedback

Most likely, one of your bash login scripts (.bashrc or .bash_profile) is changing $PATH. If you start Eclipse from the terminal, does it get /usr/local/bin in its path?

link|improve this answer
good call! If I run Eclipse from the terminal, it has /usr/local/bin in the path. Now what should I do? Isn't /usr/local/bin something that should be in the path to all applications? which script can I put this in, so that if I run Eclipse from Finder or from the Dock, it will be in the path? – Jason S Aug 23 '09 at 19:32
Also I don't have a .bashrc or .bash_profile in my user directory. – Jason S Aug 23 '09 at 19:33
feedback
up vote 1 down vote accepted

Aha, I found this webpage which says

Note: Mac OS X does not include /usr/local/bin in its default PATH. Therefore, assuming you're using the default bash shell, please type (or include in /etc/profile) export PATH=/usr/local/bin:$PATH before using any of these tools.

Is this an appropriate/inappropriate thing to do? I get leery of editing system files unless I really know what I'm doing. /usr/local/bin is only writeable by root so I wouldn't be opening a security hole, would I?


Odd, I added the export path, and it has no effect on eclipse run from the Dock. Also I found this page about paths and my /etc/paths file has

/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin

and yet those paths don't show up in eclipse... is there an easy way to create/find a binary file that prints out $PATH, that I could run from the Dock, so I could debug this more easily? I don't know if Eclipse mucks around with the path.

link|improve this answer
+1 for your final question. I'm wondering how to diagnose path issues in OS X not in bash or the Terminal. – fideli Jan 21 '10 at 0:19
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.