0

I am having huge problems with my PATH and LD_LIBRARY_PATH since I have installed new libraries. Generally speaking: I can't export permanently my PATH variables defined in my ~/.bashrc file. As example: when I boot and I type which mpiexec, I would expect the one linked to my mpich library defined in my~/.bashrc file, however, I get another one which is:

/usr/bin/mpiexec // vs expected output: /home/mpich/bin/mpiexec

So every time I need to manually type: PATH=/home/mpich/bin:$PATH ; export PATH, and I can't live with this as I have multiple libraries.

What I did:

  1. Modify the bashrc with all my libraries using: sudo nano ~/.bashrc, Output:

    export PATH=$PATH:/usr/local/cuda-10.1/bin

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.1/lib64

    export CUDA_HOME=/usr/local/cuda-10.1

    export PATH=$PATH:/snap/bin

    export PATH=$PATH:/usr/bin

    epxort PATH=$PATH:/bin

    export PATH=$PATH:/home/mpich/bin

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/mpich/lib

    export PATH=$PATH:/home/opt/openmpi/bin

    export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/home/opt/openmpi/lib

  2. Edit the environment variables in /etc/environment Output:

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/home/mpich/bin:/home/opt/openmpi/bin"

  1. type $ source ~./bashrc
  2. reboot

However, none of the above allow me to retrieve my PATH variables when booting.

So my question is : Where is the error relying and how could I export permanently my path variables defined in ~/.bashrc ? I am running on Ubuntu 18.04.

Any help would be more than appreciated as I have been spending hours on this problem. Thanks in advance

Joachim Bsh
  • 135
  • 1
  • 7
  • (1) Instead of typing `ls` after `cd`, type `pwd` - you will likely see you are already *in* `/home/joachim` (2) `export PATH=/usr/local/cuda-10.1/bin` overwrites anything you assigned in `/etc/environment` (3) in `~/.bashrc` you add `/usr/bin` to `$PATH` but not `/bin` so it's no surprise that `/bin/ls` is not found – steeldriver Sep 19 '20 at 08:28
  • @steeldriver thanks a lot for your response. The first point works indeed. For the second, I have edited this path as the others, and updated my question. Is it correct so ? (see my updated question). For the third point, I added the /bin folder and indeed typing `ls` now works, but still, there are other path variables which are still not taken into account (see updated question). Thank you anyway for your fast answer – Joachim Bsh Sep 19 '20 at 09:01
  • 2
    just as a [note](https://unix.stackexchange.com/a/26059). –  Sep 19 '20 at 11:50
  • 1
    As @bacon's link points out, order is important - since you append `/usr/bin` then append `/home/mpich/bin`, it is expected that `which mpiexec` will find the former first – steeldriver Sep 19 '20 at 12:28

0 Answers0