compiling from source install question

I’ve been compiling things from source for years, but never really understood how to make something a “system default.” I need to compile OpenMPI and did so, but now I’m not sure how to make it the system default. I tried mpi-switcher-menu but the version I compiled (in /usr/local/Ompi) doesn’t even show up in the menu. I’ve heard of various “tricks,” like prepending the particular MPI’s directory you want to use, but which seems to find only the system default. (You can see below that the system default OpenMPI is still being found - and I’m not sure if I change the system default that I won’t break something else…)

Setting up Intel Compilers...
Intel Compilers Ready!
patti@OS-Linux:~> which mpicc
/usr/lib64/mpi/gcc/openmpi/bin/mpicc
patti@OS-Linux:~> which mpich
which: no mpich in (/opt/intel/composer_xe_2011_sp1.10.319/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/bin/intel64:/usr/lib64/mpi/gcc/openmpi/bin:/home/patti/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/bin/intel64)
patti@OS-Linux:~> which mpif90
**/usr/lib64/mpi/gcc/openmpi/bin/mpif90**
patti@OS-Linux:~> mpi-selector-menu
Current system default: openmpi-1.4.3
Current user default:   <none>

    "u" and "s" modifiers can be added to numeric and "U"
    commands to specify "user" or "system-wide".

1. openmpi-1.4.3
U. Unset default
Q. Quit

Selection (1-1[us], U[us], Q):

(CODE wrapped - please move to compilers/scripting forum - thanks!!)

Hi
Its all the order of your PATH and env user settings, you need to tweak your ~/.profile and adjust as required.

Check the output from the following commands;


env
echo $PATH

The library path can also be tweaked on the fly with LD_LIBRARY env
setting. You can also script it into you ~/bin directory so it just
sets up for that shell session.


Cheers Malcolm °¿° (Linux Counter #276890)
SUSE Linux Enterprise Desktop 11 (x86_64) Kernel 3.0.31-0.9-default
up 23:17, 3 users, load average: 0.43, 0.25, 0.23
CPU Intel i5 CPU M520@2.40GHz | Intel Arrandale GPU

Thanks for the reply, Malcom! I knew a little about the PATH and LD_LIBRARY_PATH statements, but not env. I know how to

export PATH=/somepath:$PATH
(although I don't know how/why this is different:  export PATH=/somepath:{$PATH}        )

I guess I’ll check to see if there’s a man page on ‘env’
I’ve never used .profile, only .bashrc. I’m not exactly what sticks where and when. I think if I .bashrc something like:

PATH=/somepath:$PATH 

then it will prepend /somepath and leave $PATH alone between launches of the bash shell. But if I put that in .profile, it will keep prepending a new instance of /somepath to $PATH so that it gets bigger with each boot.

I found a man page for env - it’s unclear - hmmmm… I wonder if there’s a single text file somewhere that has all the information in it and is editable?

Setting up Intel Compilers...
Intel Compilers Ready!
patti@OS-Linux:~> env
LESSKEY=/etc/lesskey.bin
MKLROOT=/opt/intel/composer_xe_2011_sp1.10.319/mkl
XDG_VTNR=7
NNTPSERVER=news
KDE_MULTIHEAD=false
XDG_SESSION_ID=c1
DM_CONTROL=/var/run/xdmctl
HOSTNAME=OS-Linux
XKEYSYMDB=/usr/X11R6/lib/X11/XKeysymDB
IPPROOT=/opt/intel/composer_xe_2011_sp1.10.319/ipp
TERM=xterm
SHELL=/bin/bash
HOST=OS-Linux
HISTSIZE=1000
XDG_SESSION_COOKIE=c237019533d2c1bec9d7213700000b65-1340498932.523653-1842030086
XDM_MANAGED=method=classic,auto
PROFILEREAD=true
GTK2_RC_FILES=/etc/gtk-2.0/gtkrc:/home/patti/.gtkrc-2.0-kde4:/home/patti/.gtkrc-2.0-qtengine:/home/patti/.gtkrc-2.0:/home/patti/.kde4/share/config/gtkrc-2.0
KONSOLE_DBUS_SERVICE=:1.2181
TMPDIR=/tmp
JASPERINC=/usr/local/Jasper19001_IFORT/include
LIBRARY_PATH=/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/../compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/../compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/../compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/../compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21:
GTK_RC_FILES=/etc/gtk/gtkrc:/home/patti/.gtkrc:/home/patti/.kde4/share/config/gtkrc                                                       
GS_LIB=/home/patti/.fonts                                                                                                                 
WINDOWID=46137680                                                                                                                         
MORE=-sl                                                                                                                                  
FPATH=/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include
XSESSION_IS_UP=yes                                                                                                                        
SHELL_SESSION_ID=bb89714204d7400085dfb345ff06abd7                                                                                         
KDE_FULL_SESSION=true                                                                                                                     
USER=patti
JRE_HOME=/usr/lib64/jvm/jre
LS_COLORS=no=00:fi=00:di=01;34:ln=00;36:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=41;33;01:ex=00;32:*.cmd=00;32:*.exe=01;32:*.com=01;32:*.bat=01;32:*.btm=01;32:*.dll=01;32:*.tar=00;31:*.tbz=00;31:*.tgz=00;31:*.rpm=00;31:*.deb=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.lzma=00;31:*.zip=00;31:*.zoo=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.tb2=00;31:*.tz2=00;31:*.tbz2=00;31:*.xz=00;31:*.avi=01;35:*.bmp=01;35:*.fli=01;35:*.gif=01;35:*.jpg=01;35:*.jpeg=01;35:*.mng=01;35:*.mov=01;35:*.mpg=01;35:*.pcx=01;35:*.pbm=01;35:*.pgm=01;35:*.png=01;35:*.ppm=01;35:*.tga=01;35:*.tif=01;35:*.xbm=01;35:*.xpm=01;35:*.dl=01;35:*.gl=01;35:*.wmv=01;35:*.aiff=00;32:*.au=00;32:*.mid=00;32:*.mp3=00;32:*.ogg=00;32:*.voc=00;32:*.wav=00;32:
LD_LIBRARY_PATH=/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/../compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/../compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/../compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/../compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/../compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/../compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/tbb/lib/intel64//cc4.1.0_libc2.4_kernel2.6.16.21:/usr/lib64/mpi/gcc/openmpi/lib64:/opt/intel/composer_xe_2011_sp1.10.319/debugger/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/debugger/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/debugger/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/debugger/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/debugger/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/debugger/lib/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/lib/intel64
WRFIO_NCD_LARGE_FILE_SUPPORT=1
PILOTPORT=usb:
XNLSPATH=/usr/share/X11/nls
HOSTTYPE=x86_64
CPATH=/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/tbb/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/tbb/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/tbb/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/tbb/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/tbb/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/tbb/include
FROM_HEADER=
SESSION_MANAGER=local/OS-Linux:@/tmp/.ICE-unix/1542,unix/OS-Linux:/tmp/.ICE-unix/1542
CONFIG_SITE=/usr/share/site/x86_64-unknown-linux-gnu
PAGER=less
CSHEDIT=emacs
XDG_CONFIG_DIRS=/etc/xdg
MINICOM=-c on
NLSPATH=/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/debugger/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/debugger/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/debugger/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/debugger/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/debugger/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/compiler/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/ipp/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/mkl/lib/intel64/locale/%l_%t/%N:/opt/intel/composer_xe_2011_sp1.10.319/debugger/intel64/locale/%l_%t/%N
DESKTOP_SESSION=default
PATH=/opt/intel/composer_xe_2011_sp1.10.319/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/bin/intel64:/usr/lib64/mpi/gcc/openmpi/bin:/home/patti/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/usr/lib/mit/bin:/usr/lib/mit/sbin:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/bin/intel64:/opt/intel/composer_xe_2011_sp1.10.319/mpirt/bin/intel64
MAIL=/var/spool/mail/patti
CPU=x86_64
QT_IM_MODULE=xim
JAVA_BINDIR=/usr/lib64/jvm/java/bin
TBBROOT=/opt/intel/composer_xe_2011_sp1.10.319/tbb
JASPERLIB=/usr/local/Jasper19001_IFORT/lib64
PWD=/home/patti
INPUTRC=/home/patti/.inputrc
XMODIFIERS=@im=local
JAVA_HOME=/usr/lib64/jvm/java
LANG=en_US.UTF-8
KDE_SESSION_UID=1000
PYTHONSTARTUP=/etc/pythonstart
SDK_HOME=/usr/lib64/jvm/java
KONSOLE_DBUS_SESSION=/Sessions/1
GPG_TTY=/dev/pts/1
JDK_HOME=/usr/lib64/jvm/java
COLORFGBG=15;0
QT_SYSTEM_DIR=/usr/share/desktop-data
SHLVL=2
XDG_SEAT=seat0source /opt/intel/bin/ifortvars.sh intel64
HOME=/home/patti
OSTYPE=linux
KDE_SESSION_VERSION=4
ALSA_CONFIG_PATH=/etc/alsa-pulse.conf
SDL_AUDIODRIVER=pulse
LANGUAGE=
LESS_ADVANCED_PREPROCESSOR=no
LS_OPTIONS=-N --color=tty -T 0
XCURSOR_THEME=DMZ
WINDOWMANAGER=/usr/bin/startkde
NETCDF=/usr/local/NetCDF413_IFORT
LESS=-M -I -R
G_FILENAME_ENCODING=@locale,UTF-8,ISO-8859-15,CP1252
LOGNAME=patti
MACHTYPE=x86_64-suse-linux
CVS_RSH=ssh
DBUS_SESSION_BUS_ADDRESS=unix:abstract=/tmp/dbus-7IIB0BU2Ct,guid=72a40f42e03497b25694c2ea00000011
XDG_DATA_DIRS=/usr/share
LESSOPEN=lessopen.sh %s
USE_FAM=
WINDOWPATH=7
PROFILEHOME=
XDG_RUNTIME_DIR=/run/user/patti
DISPLAY=:0
QT_PLUGIN_PATH=/home/patti/.kde4/lib64/kde4/plugins/:/usr/lib64/kde4/plugins/
INCLUDE=/opt/intel/composer_xe_2011_sp1.10.319/ipp/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/ipp/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/ipp/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/ipp/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/ipp/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include:/opt/intel/composer_xe_2011_sp1.10.319/ipp/include:/opt/intel/composer_xe_2011_sp1.10.319/mkl/include
GTK_IM_MODULE=cedilla
XAUTHLOCALHOSTNAME=OS-Linux
LESSCLOSE=lessclose.sh %s %s
QT_IM_SWITCHER=imsw-multi
G_BROKEN_FILENAMES=1
COLORTERM=1
JAVA_ROOT=/usr/lib64/jvm/java
mc=() {  . /usr/share/mc/mc-wrapper.sh
}
_=/usr/bin/env
patti@OS-Linux:~> 

I just now ran across something that I never noticed before and am now confused about - when I set up the intel compilers, I do it with a source command in .bashrc:

source /opt/intel/bin/ifortvars.sh intel64

Now that I actually think about it - that is a shell file - and I presume executable! So why am ‘sourcing’ it rather than running it?

To the last question

Sourcing is as if the lines were in the place where the source statement is. That means the lines are executed in the same process that runs where the source statement is. Caling a scritp makes this a seperate process. That looks unimportant until you realise that when the called/sourced script contains:

MONKEY="Langur"

when sourced, it is as if this statement was in place of the source statement, which means that that value is available for the rest of the calling script/process.
While, when it is done in a seperate process, it is only available in the seperate process and thus unknown (or unaltered if MONKEY was allready defined) in the calling process.

Thus when you need the statements to influence the currecnt script/process (mostly that will be setting variables like MONKEY here), you should source, else you will have nothing. The obvious example being .profile., which is sourced to make all the settings there available to the calling process (the login shell) and thus most of them (being exported to the environment) to all the offspring processes during your session.

Such a bunch of statements to be sourced is normaly not made executable (why should it, it is not executed as a pocess), and it does not need a “shebang” (the #!/bin/bash) as the first line (the statements are executed by the shell that executes the main script, that is the process). Thus imho because these two things are not needed, they should not be there, only creating confusion when they are.

export PATH=/somepath:{$PATH}

I do not know where you found this, but it will result in a weird PATH value where the first and last variable of the original PATH will be destroyed because they are no longer directory pathes. See here:

henk@boven:~> echo $PATH
/home/henk/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/home/henk/.local/bin
henk@boven:~> which vi mmcheck
/usr/bin/vi
/home/henk/bin/mmcheck
henk@boven:~> PATH=/lala/lolo:{$PATH}
henk@boven:~> echo $PATH
/lala/lolo:{/home/henk/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/home/henk/.local/bin}
henk@boven:~> which vi mmcheck
/usr/bin/vi
which: no mmcheck in (/lala/lolo:{/home/henk/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/jvm/jre/bin:/home/henk/.local/bin})
henk@boven:~>

Because the second item in the PATH variable is now {/home/henk/bin, which does not exist of course, executables in /home/henk/bin can not be found anymore.

OK, I found that syntax (with the “{}”) somewhere online but couldn’t find what it actually meant. Thanks for telling me it must have been an error on that web page. :slight_smile:

If I understand the responses to my question, priority of use is set by first encounter along the path - hence always prepend the directory containing the libs/exes you want used. The trouble I have is that some software spawns shells of various types and so the PATH variable may change within scripts. So I was sort of looking for an system-wide analog to Windows’ PATH variable - something all shells would inherit.

I am not quite sure I understand what you mean, but instead I will simply try to explain how it works with environment variables.

A process inherits all the variables from it’s parent. It may change them, but that will only influence child processes, never parents.

This is all true for all processes, does not matter if the process runs a shell. But when it is a shell, it is of course easy to change things in the program (the shell script), it is less easier in a binary executable, because that involved compiling. But a binary executable can of course also change environment variables and spawn off new processes that will then have the changed variables.

What Windows does or does not I have almost no knowledge about, thus I can not help you here because I can not follow you in your comparisson.

And about silly things in web-sites. I would allways prefer the man pages. And* man bash t*ells:

PATH
The search path for commands. It is a colon-separated list of directories in which the shell looks for commands (see COMMAND EXECUTION below). A zero-length (null) directory name in the value of PATH indicates the current directory. A null directory name may appear as two adjacent colons, or as an initial or trailing colon. The default path is system-dependent, and is set by the administrator who installs bash. A common value is ``/usr/gnu/bin:/usr/local/bin:/usr/ucb:/bin:/usr/bin’'.

Thus the : seperated items should contain directories. And as most directories have no { or } in their names, adding these characters to the string that is the value of PATH is most often not a good idea IMHO.

Thanks!!!