0

This question already has an answer here:

I'm only able to install new tool in my local directory.

After ./configure --prefix=/local/directory, new tool is installed my local bin.

But by default it's still point to the old version.

How to force csh to use local installed version?

marked as duplicate by steeldriver, G-Man, DarkHeart, Archemar, Hauke Laging Mar 11 '18 at 9:43

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • I've added setenv PATH ${PATH}:/local/bin, but if I run which, it's still point to the old version. – Fisher Mar 9 '18 at 22:59
  • Unfortunately, the proposed duplicate doesn't solve the finer point here of prepending the local directory to $PATH – Jeff Schaller Mar 10 '18 at 0:38
  • Don't use csh. Use some better shell (zsh, fish, ...). Read absolutely Csh Programming Considered Harmful – Basile Starynkevitch Mar 10 '18 at 3:00
5

The shell searches the directories in the order that they appear in the PATH environment variable. If there is another command with the same name in one of the other PATH directories, it will pick it up before getting to the new directory that you appended to the end of the PATH variable. You would need to prepend the new directory to the PATH environment variable.

setenv PATH /local/directory/bin:$PATH
  • I've added setenv PATH /local/directory/bin:$PATH to the first line of .cshrc. After source ~/.cshrc, run which, but it's still not picking up local/bin. Try add which before and after setenv PATH. First print old bin, second print new bin. But if I run which, still print old bin location. – Fisher Mar 10 '18 at 18:14
  • Found the reason, there are some scripts in my .cshrc secretly changed PATH. – Fisher Mar 10 '18 at 18:24

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