Strange Hadoop error caused by the CDPATH environment variable

When I tried to run hadoop in my Linux box, I got a strange error:

bin/hadoop: line 53: /home/hzhang/tools/hadoop-0.20.203/bin
/home/hzhang/tools/hadoop-0.20.203/bin/hadoop-config.sh: No such file or directory

It said the hadoop-config.sh is missing, but clearly it’s there in my machine. After hair-scratching for quite a bit, I found out that it’s the line before 53 that caused error

bin=`dirname "$0"`
bin=`cd "$bin"; pwd`

The reason is that I activated CDPATH in my shell, and the $bin variable therefore contains the same path repeated twice. All I have to do is turn it off by the following command:
$ unset CDPATH

Leave a Reply