If you set the LD_LIBRARY_PATH in a user's ~/.bashrc, it is a good idea to
add to the LD_LIBRARY_PATH, not replace it. i.e.
Code:
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/lib"
The reason applies also to MANPATH, PATH and other lists, and is as follows. The system-wide shell configuration files, /etc/profile and /etc/bash.bashrc are read
before the user-specific ~/.bashrc. Thus if the system administrator adds something to the LD_LIBRARY_PATH, perhaps for some application you use, you do not want to over-write it.
e.g. The system administrator installs a crucial package in /opt/important, and needs /opt/important/lib in the LD_LIBRARY_PATH for that application to run. He modifies the /etc/profile, setting LD_LIBRARY_PATH with this command:
Code:
export LD_LIBRARY_PATH="/opt/important/lib"
When you log in, this is executed first, and then your ~/.bashrc is executed. If you do this:
Code:
export LD_LIBRARY_PATH="/usr/local/lib"
...you will replace the original path set in the /etc/profile and the crucial app will cease functioning. You could of course explicitly set both paths in your ~/.bashrc like this:
Code:
export LD_LIBRARY_PATH="/opt/impoprtant/lib:/usr/local/lib"
...but maybe the system administrator would like to change this in the future, and it would be a pain to have to update your own ~/.bashrc each time (s)he does this. Hence the suggestion at the top of this post.
This sort of thinking is not so important if you are the sole user of your machine, but it's a good habit to get into - one day you may have to work in a large multi-user environment, and you should know how not to annoy your system administrators!