-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.

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