0

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
3
  • 1
    Could this be linked to the fact that macs now have zsh as the default shell? Where is your PATH being set? Is it in ~/.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 some echo "P:$PATH" statements in the various startup files to see if you can track it down.
    – terdon
    Commented Jul 14, 2021 at 9:06
  • I have the shell switched to bash in the preferences because I have too many machines working off of the same base files and I didn't want to take the time to learn a new shell. I was setting some $PATH variables in both .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
    Commented Jul 14, 2021 at 16:20
  • OK, thanks. Could you add some of that detail to your question so the next person won't wonder about it? Ideally, show us a minimal example that reproduces what you see. Maybe you aren't exporting PATH in bashrc? Is the _OLD_VIRTUAL_PATH variable what you expect? Where exactly does it change? You'll need to echo the contents of PATH at various times to see precisely which command is resetting it.
    – terdon
    Commented Jul 14, 2021 at 16:23

0

You must log in to answer this question.

Browse other questions tagged .