Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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
add comment

1 Answer 1

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
add comment

Your Answer

 
discard

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.