I can say this is very basic mistake done by most of the beginners.
Please follow below approach to fix the error.
I can tell you one thing when you define them in your .bashrc file, it is really good and well defined for the your user.
But when you launch a command with the use of sudo, then it will run as the super-user/root, and NOT as the your user; so your current .bashrc file is 'useless' in this scenario.
In your case you must update the environment with your system file as shown below under the /etc/profile.d for example:
You need to write below commands very carefully
sudo touch /etc/profile.d/variousPath.sh
sudo chown bsquare /etc/profile.d/variousPath.sh
cat >> /etc/profile.d/variousPath.sh <<EOF
Now you just need to restart your computer, and then your SYSTEM environment will know your
I hope it fixes your problem