-1

I have read many posts and help files about updating the PATH using .bashrc. I might have to use .bashrc_profile as discussed here.

However, I can't get .bashrc to even work from the command line.

I start with

env | grep "$PATH"
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

In .bashrc is

export PATH=~/anaconda3/bin:$PATH

Permissions of .bashrc is -rwxrw-r-- .bashrc

Execute .bashrc, path does not change.

~$  env | grep "$PATH"
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin
~$ ./.bashrc
~$  env | grep "$PATH"
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

Entering directly on the command line works.

~$ export PATH=~/anaconda3/bin:$PATH
~$  env | grep "$PATH"
PATH=/home/ksmith/anaconda3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/snap/bin

What am I doing wrong? [My 'Nix is Ubuntu]

Once I can prove that .bashrc updates PATH, I will rename it to .bashrc_profile to test that PATH is updated when logging on.

KeithSmith
  • 101
  • 5
  • 4
    Possible duplicate of [How to correctly add a path to PATH?](http://unix.stackexchange.com/questions/26047/how-to-correctly-add-a-path-to-path) – jasonwryan Nov 20 '16 at 20:13
  • 1
    Not a duplicate of 'How to correctly add a path to PATH?'. it is a lower level problem. – hildred Nov 20 '16 at 22:18

1 Answers1

3
~$ ./.bashrc

This is the problem. If you run .bashrc as a program, it gets its own copy of the environment, and any changes it makes are not propagated back to the shell. You need to invoke .bashrc by "sourcing" it instead:

source ./.bashrc

Or, for short:

. ./.bashrc
DepressedDaniel
  • 4,169
  • 12
  • 15