I have a script called jsl in /usr/local/bin. Running which jsl finds it there.
I want to temporarily use a different version, and when I echo $PATH I see that /usr/bin is earlier in the path. So I added a script called jsl in that folder and I’ve verified that it is executable and runs correctly when called with the full path.
However, which jsl still finds the first version, and jsl still runs it.
Why isn’t my new jsl being found by which or executed by name?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
The shell might be caching the command’s location. E.g. zsh does this, and has the rehash command to clear the cache.
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0