Why does Bash give "No such file or directory" for a program that's in my PATH?

You have installed docker-compose once in one place. Then you deleted it and installed it in another location.

In that way, you have run into an optimization of bash for not having to search $PATH every time you type a command, by caching the results in memory. The path hash is a hash-table, maintained by bash, that contains the locations on disk where the shell should look for executable programs when a command is run. The hash table gets cleared on events that obviously invalidate the results (such as modifying $PATH), or by using the inbuilt hash command.

When you executed docker-compose again, bash just tried to get it from where it found it the last time, only that it wasn't there any more, so you got that error message.

To invalidate the hash for docker-compose, run the command:

 hash docker-compose

Tags:

Linux

Bash

Path