I have a virtual environment which I usually activate by default in my bashrc via source ~/.venv/env/bin/activate
. This has been working fine on an old MacBook Air and Linux Desktops and servers (I use the same bashrc with some different conditional blocks for each machine)
I just got a new MacBook and I was setting everything up and I found that when calling the activate
command above, my $PATH environment variable gets overwritten which messes up everything that was added to it before. The only line I can see in activate which modifies the path is below, but I cannot see why it would be overwriting it. Any ideas?
_OLD_VIRTUAL_PATH="$PATH"
PATH="$VIRTUAL_ENV/bin:$PATH"
export PATH
~/.bashrc
or in~/.profile
or somewhere else? Also, Macs used to launch login shells by default, at least before switching to zsh, which means they don't read bashrc. Is that still the case? Try adding someecho "P:$PATH"
statements in the various startup files to see if you can track it down. – terdon Jul 14 '21 at 09:06.bashrc
and.profile
due to recommendations of different tools. this particular code is running in.bashrc
so I can be sure it is running and I have narrowed it down to directly before and after the sourcing of the python environment. Before sourcing, everything in the path is correct. – Joff Jul 14 '21 at 16:20export
ingPATH
in bashrc? Is the_OLD_VIRTUAL_PATH
variable what you expect? Where exactly does it change? You'll need to echo the contents ofPATH
at various times to see precisely which command is resetting it. – terdon Jul 14 '21 at 16:23