0

I'm installing protocolbuf on my CentOS 7 box, and after installation, I saw some inconsistency while running the protoc compiler binary:

$  which protoc
/usr/local/bin/protoc 
$  protoc
bash: /bin/protoc: No such file or directory

This definitely looks wrong, how do I fix this problem?

Chen Xie
  • 103

1 Answers1

3

With modern shells they remember the path to a command you previously ran. So, for example:

bash-4.2$ hash
hash: hash table empty
bash-4.2$ whoami
sweh
bash-4.2$ hash
hits    command
   1    /usr/bin/whoami

Now if you remove a program (in your case /bin/protoc) and install it in a new location (/usr/local/bin/protoc) the current shell will try the old location. And it fails, because the old file isn't there.

You can tell the shell to forget all remembered paths with hash -r.

That will force it to search the path again.

The which command doesn't understand the current shell's hash. The type command is a shell builtin that's more accurate.