I fiddled with my $PATH and now it's not working correctly anymore. So I thought, well, just remove the last things I added. However, I can't seem to figure out how. I added things like so

export MAGICK_HOME="/Library/ImageMagick-6.7.5/"
export PATH="$MAGICK_HOME/bin:$PATH"

I do not have the files ~/.bash_login or ~/.profile or /etc/environment. I can't find the mentioned strings in /etc/path or /etc/bashrc. I don't know a command except export, that manipulates the $PATH.

How do I get rid of these strings? (And, if it's obvious to you, what did I mess up?)

  • How did you add them if not in ~/.bash_login or ~/.profile ? – mmmmmm Mar 17 '12 at 12:27
  • What is the current value of $PATH (echo $PATH)? – nohillside Mar 17 '12 at 13:21
  • @Mark like it said, it added them using export in terminal. – albifant Mar 17 '12 at 16:33
  • @patrix echo $PATH: /usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/texbin:$HOME/ImageMagick-6.7.5/bin:$MAGICK_HOME/bin:$PATH – albifant Mar 17 '12 at 16:34

If you just typed in the exports into the terminal as noted above then the variables in the environment will only last until you exit that terminal session. So simply typing exit and then reopening another terminal will remove any setting that you applied with the noted exports performed in your question.

export MAGICK_HOME="/Library/ImageMagick-6.7.5/"
export PATH="$MAGICK_HOME/bin:$PATH"

Additionally you can un set variables from the environment by using the unset command.

For example:

unset MAGICK_HOME # will remove MAGICK_HOME from the environment. 

You can do it for the others as well but if you do it for PATH you will lose your path setting until you close this terminal session and reopen a new window,etc.

As an experiment try typing:

env | grep MAGICK_HOME

You should see MAGICK_HOME=/Library/ImageMagick-6.7.5/ echoed back if its still in the environment. If its not then the settings have already been lost by a windows close. etc re-enter your export of MAGICK_HOME and try the above command again.



and then finally re open a new terminal window and enter:

env | grep MAGICK_HOME 

Your settings should be gone for MAGICK_HOME. The same is true for the modification done to all the other environment variables set with the export command right in a terminal session. They will just return to their default values if you have not set them in a start-up invocation file as required for your shell environment variables to have a more permanent place in your shell enviorment.

  • Just a follow-up. The DYLD_LIBRARY_PATH shouldn't be set to ImageMagick's libs anyway. That might have messed up more things than it solved. That ENV should be appended to. Also your assumption about the user setting $PATH using the prompt as opposed to coding it into a startup configuration file seems to be correct. – ismail Mar 17 '12 at 15:17
  • Right. This would have been the correct answer. In this particular case the problem was sitting in front of the Mac. I had set the variables in /etc/launchd.conf and forgot about it. I found them using "grep "MAGICK_HOME" -R . " in etc. Clearing out that file and rebooting fixed the problem for me. – albifant Mar 17 '12 at 17:27

To remove a path element in a running shell you can run the following script:

for p in $(echo -e ${PATH//:/\\n}); do
    if [[ $p != /PATH/TO/REMOVE ]]; then

replacing /PATH/TO/REMOVE with the PATH you want to remove.


Have a look in /etc/paths.d. Since Snow Leopard the 'preferred' way of adding stuff to your shell path is to add a nice little text file in /etc/paths.d.

For instance, I have MacGPG2 installed, and lo and behold:

$>ls /etc/paths.d
50-X11  MacGPG2  TeX  TeXbin  git

$>cat MacGPG2 

$>echo $PATH

Removing the text files from /etc/paths.d seems to be the first port of call to remove stuff from the $PATH

  • Thanks, I didn't know that. In /etc/paths.d are files (like a recently new one for TeX) but not the ones I want to remove :( – albifant Mar 17 '12 at 16:45

You must log in to answer this question.

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