Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are the various files that could have PATH declarations for OS X Terminal in them?

So I'm having a path issue on OS X Leopard. It seems OS X is adding other paths that I'm not stating and it's messing with my path priority. I only have a .bash_login file, I don't have a .bashrc or a .profile file. My .bash_login file is as such:

export PATH="/usr/local/bin:/usr/local/sbin:/usr/local/mysql/bin:$PATH"

When I run export this is the path it returns:

PATH="/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/opt/local/bin:/usr/local/git/bin"

Any ideas on what could be putting /usr/bin in there and how I could get /usr/local/bin to be a higher priority.

I'm tagging this for Rails too because that's what I'm working on right now... it seems the Mac built-in Ruby, Rails, and Gems are taking priority over the one I have installed at /usr/local/bin, figured maybe you fellow Rubyists could help too.

like image 391
Tim Knight Avatar asked Dec 07 '08 05:12

Tim Knight


3 Answers

Have you looked inside these two directories:

/etc/paths.d/
/etc/manpaths.d

Any paths defined in files in those directories get appended automatically to PATH variable -- I mostly use those two directories to put third-party installed applications in the PATH. Also, do have a look at the man page of path_helper on OS X.

EDIT: Looking at the contents of /etc/profile, I can see that path_helper is executed first. The man page for path_helper says that prior to reading files in /etc/paths.d/ and /etc/manpaths.d/ directories, path_helper reads and sets up the paths defined in the files /etc/paths and /etc/manpaths. A look at /etc/paths reveals this:

$ cat /etc/paths
/usr/bin
/bin
/usr/sbin
/sbin
/usr/local/bin

And, I believe, those account for the half of what you are seeing as set in PATH.

like image 101
ayaz Avatar answered Nov 14 '22 20:11

ayaz


It looks like your changes aren't being applied. Note no /usr/local/mysql/bin

Read the bash manpage section on INVOCATION, .bash_login is only read if it is a login shell -- which the terminal shell is not. You need to put it into ~/.bashrc instead. It will be read for logins and non-login shells.

like image 4
Brian C. Lane Avatar answered Nov 14 '22 22:11

Brian C. Lane


You can also put stuff into ~/.MacOSX/Environment.plist, as detailed at https://web.archive.org/web/20150330034300/http://www.astro.washington.edu/users/rowen/AquaEnvVar.html

This will make the Environment Variables available to all applications, not just those started through a terminal (bash) session.

(It seems that there is a better suggestion there now, too)

like image 1
Matthew Schinckel Avatar answered Nov 14 '22 20:11

Matthew Schinckel