Executable not found although in PATH

Posted on

Problem :

My $PATH is set to a lot of directories including ~/bin and ~/target/bin

I want to execute script.sh which is in ~/target/bin but I get the error bash: ~/bin/script.sh: No such file or directory

This confuses me since which finds the correct directory ~/target/bin and ~/target/bin/script.sh executes fine.

Are there any special settings in bash that could lead to this wrong path handling?

Solution :

You might try running hash -r to clear the executable cache.

Bash saves the location of the executable in a cache so it doesn’t have to search the entire path again if you re-run the command. More on the hash command

Leave a Reply

Your email address will not be published. Required fields are marked *