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

ぐ巨炮叔叔 提交于 2019-11-30 09:52:42

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.

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.

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)

I've also come across an interesting article on Apple's support forums:

.bash_login no longer executed

With that information I found an overlooked blank .bash_profile file that I had that was loading - and killing all of the information I was trying to set in my path.

So I guess it looks like we could have several "correct" answers depending on the situation.

Just put in .bashrc or .login and you'll be fine

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!