Bash: <app> returns a different location than expected

Can someone explain to me why the following is happening?

[$] pip
-bash: /usr/local/bin/pip: No such file or directory
[$] which pip
/bin/pip

      

+3


source to share


1 answer


App search is cached. Reset entry pip

:

hash pip

      

Quote man bash

:

If the name is neither a shell function nor a built-in, and does not contain a forward slash, bash searches for every PATH entry for the directory containing the executable with that name. bash uses a hash table to remember the full paths to executable files (see the hash code in the SHELL BUILTIN COMMANDS section below). A full search of 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 fully qualified command file name is determined by searching directories in $ PATH and remembered.

which

always looking for your path, regardless of the hash entry.

+5


source







All Articles