Can't find binary, but path included in $PATH

So I tried to install Mercurial on Ubuntu 10.04. First I used the ppa repo, but got a pythonpath error, which I gave up on. Next try was install from source, everything went well, except it can't find hg:

$ hg
-bash: /usr/bin/hg: No such file or directory

However, hg is installed in /usr/local/bin/ :

$ which hg
/usr/local/bin/hg

The PATH includes this directory, so why is hg not found?

$ echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games

If I execute hg with the full path it works:

$ /usr/local/bin/hg --version

Any help is really appreciated!


Bash maintains a cache of locations of executables in $PATH. You had hg in /usr/bin at some point, and ran it from that shell. Now you've removed /usr/bin/hg. You need to tell your running shell to forget this location:

hash hg

A new shell wouldn't have this problem, since the cache isn't shared between shell instances.