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
  • could do a sym link from /bin/protoc to /usr/local/bin/protoc. There is probably a better way but that would make it run. Commented Feb 10, 2020 at 23:58
  • What does type protoc say? Commented Feb 11, 2020 at 0:00
  • @StephenHarris it says protoc is hashed (/bin/protoc) Commented Feb 11, 2020 at 0:08
  • That sounds like you used to have a /bin/protoc but removed it. So try hash -r. That will cause bash to forget the old name and look on the path again. Commented Feb 11, 2020 at 0:09
  • 1
    This is unix.stackexchange.com/q/535632/5132 and unix.stackexchange.com/q/82991/5132 and unix.stackexchange.com/q/474116/5132 again. Commented Feb 11, 2020 at 4:21

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.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.