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?

6

1 Answer 1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.