1

A command has been added to the $PATH, but I cannot find the place that the path has been added to $PATH. Please see that which shows the full path to the binary file, however looking into .bashrc, .bash_profile, /etc/profile and /etc/profile.d returns no result. Please note that the matches in the grep relates to something else.

How can I find where does this path had been added to $PATH?

# which mpicc
/opt/openmpi/bin/mpicc
# grep -r openmpi .bash_profile
# grep -r openmpi .bashrc
alias of230='module load openmpi-x86_64; source /export/apps/mechanics/OpenFOAM/OpenFOAM-2.3.0/etc/bashrc WM_NCOMPPROCS=4 foamCompiler=ThirdParty WM_COMPILER=Gcc48 WM_MPLIB=SYSTEMOPENMPI'
# grep -r openmpi /etc/profile
alias of230='module load openmpi-x86_64; source /export/apps/mechanics/OpenFOAM/OpenFOAM-2.3.0/etc/bashrc WM_NCOMPPROCS=4 foamCompiler=ThirdParty WM_COMPILER=Gcc48 WM_MPLIB=SYSTEMOPENMPI'
# grep -r openmpi /etc/profile.d/
/etc/profile.d/rocks-hpc.csh:# Add default module definition for rocks-openmpi.
/etc/profile.d/rocks-hpc.csh:# Load the rocks-openmpi module if ROCKS_USER_MODULE_DEF not defined
/etc/profile.d/rocks-hpc.csh:   module -s add rocks-openmpi
/etc/profile.d/rocks-hpc.sh:# load the defaults rocks-openmpi module
/etc/profile.d/rocks-hpc.sh:# Add default module definition for rocks-openmpi.
/etc/profile.d/rocks-hpc.sh:    module add rocks-openmpi 2>/dev/null

Please also see the $PATH

# echo $PATH
/opt/openmpi/bin:/usr/lib64/qt-3.3/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/bio/ncbi/bin:/opt/bio/mpiblast/bin:/opt/bio/EMBOSS/bin:/opt/bio/clustalw/bin:/opt/bio/tcoffee/bin:/opt/bio/hmmer/bin:/opt/bio/phylip/exe:/opt/bio/mrbayes:/opt/bio/fasta:/opt/bio/glimmer/bin:/opt/bio/glimmer/scripts:/opt/bio/gromacs/bin:/opt/bio/gmap/bin:/opt/bio/tigr/bin:/opt/bio/autodocksuite/bin:/opt/bio/wgs/bin:/opt/eclipse:/opt/ganglia/bin:/opt/ganglia/sbin:/usr/java/latest/bin:/opt/maven/bin:/opt/maui/bin:/opt/torque/bin:/opt/torque/sbin:/opt/pdsh/bin:/opt/rocks/bin:/opt/rocks/sbin:/opt/condor/bin:/opt/condor/sbin:/opt/gridengine/bin/linux-x64:/export/apps/mathematics/matlab2012a/bin:/opt/maui/bin:/export/apps/mathematics/matlab2012a/bin:/export/apps/mathematics/Mathematica/10.3/Executables:/usr/local/chem/g09-64-D01:/home/mahmood/bin:/opt/maui/bin:/opt/torque/bin:/opt/torque/sbin
  • Please edit your question and clarify. What command has been added to $PATH? mpicc? What is run when you run it and what were you expecting to run? If mpicc was added, why are you searching for openmpi? – terdon Jul 13 '16 at 12:55
  • OK, I see, openmpi is part of the target path. It would be nice to edit and clarify that though. Also, please show us the output of echo $PATH so we can know what was added. – terdon Jul 13 '16 at 13:12
1

The machine you're working on seems to have some sort of module system for dynamically making software available, possibly the "Modules" system (link currently dead because SourceForge is down).

I'm on a system which uses Modules too:

$ type mpicc
-ksh93: whence: mpicc: not found
$ module load openmpi
$ type mpicc
mpicc is a tracked alias for /opt/openmpi/1.7.5gcc4.4/bin/mpicc

The modules are being looked for in the directories listed in $LMOD_DEFAULT_MODULEPATH. In one of these directories, I find the file openmpi/default.lua. This file is a Lua script.

In the script:

local mpipath= "/opt/openmpi/" .. useVer .. usedComp .. compVer
prepend_path("PATH",            pathJoin(mpipath, "bin"))

(these are not consecutive lines in the script)

Note: I've never used Modules myself, so I don't know if the setup on my system is Modules operating as default, or if it's a heavily modified local version of it.

Edit: It's either not the same, or a heavily customized version. The Modules package uses MODULESHOME (defaults to /usr/local/Modules/3.2.7 according to the manual). The mechanics would be the same. There's a module in $MODULESHOME/modulefiles somewhere that will set the PATH to what you are seeing when you type module load openmpi (or if a shell init script does this for you).

  • The output of type mpicc on my Centos is mpicc is /opt/openmpi/bin/mpicc which is different from yours. Also $LMOD_DEFAULT_MODULEPATH is empty – mahmood Jul 14 '16 at 6:27
  • @mahmood The systems are probably administrated by different people, you system and my system, so that's why the paths to mpicc are different. Now that Sourceforge is back up again: have a look at the modules manual, in particular in te FILES section. If you still can't figure it out, send an email to you sysadmin. – Kusalananda Jul 14 '16 at 6:34
0

You can check the content of /etc/environment.

This file is specifically meant for system-wide environment variable settings. It is not a script file, but rather consists of assignment expressions, one per line.

  • That file is actually empty! – mahmood Jul 13 '16 at 12:56
0

I haven't really understood what you're asking since you haven't told us what command was added. In any case, I use the following function to search through the usual suspects:

grep_bash(){
  grep -H "$@" ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login ~/.bash_aliases \
       /etc/bash.bashrc /etc/profile /etc/profile.d/* /etc/environment 2>/dev/null
}

In other words, if you're looking for openmpi, run:

grep -H "openmpi" ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login ~/.bash_aliases \
   /etc/bash.bashrc /etc/profile /etc/profile.d/* /etc/environment 2>/dev/null

Note that this will not find it if it is being set in one of the files sourced by any of the above. To get a list of sourced files, try:

grep -EH "\. |source " ~/.bashrc ~/.profile ~/.bash_profile ~/bash.login \
~/.bash_aliases    /etc/bash.bashrc /etc/profile /etc/profile.d/* \
/etc/environment 2>/dev/null

That will return a list of files sourced by your initialization files. You will then need to search through those for your string as well.

  • When there is a binary file /foo/bin/file, you have to export PATH=$PATH:/foo/bin. Your solution doesn't work – mahmood Jul 13 '16 at 13:05
  • @mahmood yes, I know you need to search for foo/bin. As I said, your question wasn't very clear so I didn't know what you should be searching for. If you know that openmpi is what you're looking for, then search for that. Did you try it? – terdon Jul 13 '16 at 13:12
  • Yes, /opt/opnempi/bin/mpicc actually exists – mahmood Jul 13 '16 at 13:24
  • @mahmood I don't doubt that it exists. Please read the answer. I am giving you a list of all the possible files where this could have been added to the $PATH. Have you tried my command yet? Did it work? – terdon Jul 13 '16 at 13:29
  • Please check the output at pastebin.com/wmr6S831 – mahmood Jul 13 '16 at 13:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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