I am doing this:
$ which cabal
/usr/bin/cabal
$ export PATH=$PATH:$HOME/.cabal/bin
$ which cabal
/usr/bin/cabal
I expect to get /.cabal/bin/cabal
for $ which cabal
(this path exists) after this. But I don't even after re-opening the terminal. How come?
Best Answer
The paths in
$PATH
are searched in order. This allows you to override a system default with:$HOME/bin
is now the first (highest priority) path. You did it the other way around, making it the last (lowest priority) path. When the shell goes looking, it uses the first match it finds.In case it's not clear, this all works by concatenating strings. An analogy:
$WORD
is nowfoobar
. The:
used with$PATH
is literal, which you can see withecho $PATH
.