Tell me more ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.)

share|improve this question

4 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.

share|improve this answer
I think this is the right answer, anyway it worked for me. – spacemanaki Dec 3 '10 at 22:44
Unfortunately, this doesn't seem to work for me. – thSoft Nov 19 '12 at 22:44

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?

share|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
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.

share|improve this answer
1  
+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

Had the same problem. Here is my solution:

  1. Edit the /etc/paths file to include the desired additional path.

  2. For a OSX installation, run /Applications/eclipse/eclipse not /Applications/eclipse/Eclipse.app

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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