Reputation: 5553
Can anyone explain to me why the following is happening?
[$] pip
-bash: /usr/local/bin/pip: No such file or directory
[$] which pip
/bin/pip
Upvotes: 3
Views: 174
Reputation: 1124110
Application lookups are cached. Reset the pip
entry:
hash pip
Quoting man bash
:
If the name is neither a shell function nor a builtin, and contains no slashes, bash searches each element of the PATH for a directory containing an executable file by that name. Bash uses a hash table to remember the full pathnames of executable files (see hash under SHELL BUILTIN COMMANDS below). A full search of the directories in PATH is performed only if the command is not found in the hash table.
and the entry for hash
in the same documentation:
hash [-lr] [-p filename] [-dt] [name]
For each name, the full file name of the command is determined by searching the directories in $PATH and remembered.
which
always searches your path regardless of the hash entry.
Upvotes: 5