Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

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

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

$ echo $PATH

If I execute hg with the full path it works:

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

Any help is really appreciated!

share|improve this question
up vote 7 down vote accepted

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.

share|improve this answer
Thanks!! So simple, but takes hours to discover if you stay in the same shell. – floorish Jun 3 '11 at 23:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.