Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I made the mistake of putting CDPATH into my .profile file just to see if it would slightly boost my productivity but found that sometimes it would cd to directories that I didn't want it to (I would need to precede them with ./ to make sure it went to the current directory rather than one defined in the environment variable that shared the same name).

I removed it from the .profile file but it still gets exported every time I launch the terminal and for the life of me I can't find what (bash) script does it.

I would search/etc and my home directory for any file the name of which resembles profile or bash and xargs grep those files to look if there were something along the lines of export CDPATH but to no avail.

Is this stored in a configuration file that cd uses? Has anyone come across a similar problem?

Needless to say I did put export CDPATH='' in my .profile, but I need to source it first for the statement to take effect.

My bash version is 4.2.24, my OS is Linux Mint 13 Cinnamon.

share|improve this question
up vote 1 down vote accepted

Your .profile will be read when you log in not when you start a new shell. This includes when you log in to a graphical display manager, which I assume you are doing ("every time I launch the terminal"). If you're in a graphical interface, log completely out of that and back in to get a fresh environment.

EDIT: For future reference, I recommend putting stuff like that in a .bashrc file instead of .profile. The .bashrc is read every time a shell is started. This page does a good job of explaining the difference in more detail.

share|improve this answer
Yes, it was indeed the issue, I was using a virtual environment whose state I was saving and once logged in, the variable was there until I would restart it. I had assumed that the CDPATH would be unset for all terminals if I did it in one but it wasn't the case. I'll keep it in mind :) – Nobilis May 26 '13 at 4:55

You must log in to answer this question.

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