Question: Does order of precedence in the PATH influence Ubuntu to choose which program to use?
More details:
I use .bashrc
for declaring private env PATH, I have installed MSP430-gcc from ubuntu repositories which stays in /usr/local/bin and I have compiled my own MSP430-gcc and placed it under /opt/compilers/msp430-gcc-4.7.3
:
#msp430-gcc 4.7.3 in .bashrc
export PATH=$PATH:/opt/compilers/mspgcc-4.7.3/bin
#the corresponding echo $PATH
/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/opt/tools/MSP430Flasher_1.3.0:/opt/compilers/Sourcery_G++_Lite/bin:/opt/compilers/mspgcc-4.7.3/bin
When I try to ask Ubuntu which MSP430-gcc it uses? It used to answer: /opt/compilers/mspgcc-4.7.3/bin
.
But now it is answering the following:
$which msp430-gcc
/usr/bin/msp430-gcc #the default installation from Ubuntu repo
Problem: I noticed the above setting was not working after an update. ( may or may not be caused by an update) I'm using Ubuntu 14.04 LTS and updated on date: 16 december 2014
Fix: I had to change the precedence of environment PATH by editing .bashrc and change the precedence and put my custom path before system's PATH as below
#msp430-gcc 4.7.3 in .bashrc
export PATH=/opt/compilers/mspgcc-4.7.3/bin:$PATH (note the difference in locating :$PATH)
#echo $PATH
/opt/compilers/mspgcc-4.7.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin:/opt/tools/MSP430Flasher_1.3.0:/opt/compilers/Sourcery_G++_Lite/bin
The story behind: This problem has already been reported (PATH appears on first has highest precedence (left to right):