Ok - so this issue has become somewhat of a white whale for me. I have browsed some of the questions here, but I cannot seem to figure out how to, very simply, delete a directory from my PATH. (I should also add that I am very to to Mac, making the transition from Windows).

So: I have gathered that I can make a .bashrc, .bash_profile, etc etc, to ADD files to my PATH. I think I get that.

However what I cannot seem to find a direct answer to, is: How do I simply delete a specific existing directory, from my PATH? This is all I would honestly like to do.

Thank you.

EDIT: Why I want to remove a directory from PATH:

Long story short, homebrew put a directory into my PATH, that it no longer needs. It says I can remove it from PATH, and so this is why I would like to remove it. Here is a screen shot:

enter image description here

  • In your .bashrc (and others), you're not limited to appending to your PATH, you can also simply define a complete PATH (ignoring whatever it used to have)... but why you would want to remove a standard entry is curious; can you say more about what you're really trying to accomplish? – mah Jun 1 '14 at 19:07
  • @mah No worries, I edited the question for the reason why. Also FWIW, I dont have a .bashrc, but if I can make one to overwrite the PATH, then I guess that would work... – TheGrapeBeyond Jun 1 '14 at 19:15

It depends where the PATH is being set. If you use bash, the path could be set in any of the following:


This list is in the order that the files are read (by bash). Later files override earlier files.

Check the above in reverse order for export PATH which will write your PATH variable.

You should be able to find where it's set by launching your shell with -x.

Also check /etc/paths and /etc/paths.d for paths that are set before your shell is started.

If all else fails, you can set the PATH yourself to override its current contents. Run echo $PATH, then paste your PATH after export PATH in your ~/.bashrc and make your desired modifications. As ~/.bashrc is the last one read, it will override any earlier modifications to your PATH.

If you use zsh, it's probably in ~/.zshrc or a sourced file.

  • 1
    Also note that most homebrew recipies are very well behaved and do not modify your configuration files. They suggest commands you can run to do the modifications at the end of the install. And do note: if you're not running bash the ways PATH get set will differ from above. – Ian C. Jun 1 '14 at 19:21
  • Hmm...so the last four files do not exist for me, and I checked the first two, but that python directory is not there... – TheGrapeBeyond Jun 1 '14 at 19:26
  • @TheGrapeBeyond What do you get if you run bash -x? You should see your PATH being set to include that directory, which you can then grep the files to find where that is. – grg Jun 1 '14 at 19:29
  • Umm...weird... I get: "++ git_info_for_prompt"...also, that messed the way the prompt looks like now... 0_0 – TheGrapeBeyond Jun 1 '14 at 19:32
  • @TheGrapeBeyond Is that all? There should be many lines that get written. (You can get back by closing/opening Terminal or pressing ⌃D) – grg Jun 1 '14 at 19:33

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .