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

Can anyone explain this?

$ vim --version
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Jul 12 2010 12:47:31)
$ `which vim` --version
VIM - Vi IMproved 7.3 (2010 Aug 15, compiled Oct 13 2011 22:52:17)

I just compiled the latest version of vim and installed it to $HOME/bin, which is the first path in $PATH. which vim returns the correct path: /home/user/bin/vim, however, when I execute vim it launches /usr/bin/vim.

I launched another xterm and the problem has disappeared, however I am still curious as to how the previous term got into such a weird state. Any ideas?

share|improve this question
up vote 4 down vote accepted

In UNIX, when you run a command, the shell saves the path where it found the binary. If you then change the path, or install a different version in directory earlier in the path, then the shell will not find it because it does not actually search for commands that it has already found.

If you had typed hash -r before comparing which vim and vim, then you would not have seen this discrepancy.

share|improve this answer
That makes perfect sense, thanks. – mwcz Oct 14 '11 at 12:41

You must log in to answer this question.

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