Environment variables override on new terminal
opened this issue · comments
I'm having troubles when opening a new terminal tab in a directory with .autoenv.sh
.
Here's how my .autoenv.sh
looks like:
source `dirname "$0:A"`/.venv/bin/activate #activates virtualenv
echo `which python` # for testing purpose
So let's say I have my first terminal and cd into the directory:
$ cd Devel/Python/my_project
/Users/redrabbit/Devel/Python/my_project/.venv/bin/python <--- echoed from .autoenv.sh
$ which python
/Users/redrabbit/Devel/Python/my_project/.venv/bin/python <--- OK
Everything OK here. I'm using python
from my $VIRTUAL_ENV
.
Now i open a new tab within the Terminal app (cmd+t
):
Last login: Sat Jun 11 14:26:34 on ttys000
/Users/redrabbit/Devel/Python/my_project/.venv/bin/python <--- echoed from .autoenv.sh
$ which python
/usr/local/bin/python <--- ??? Something went wrong here
It looks like $PATH
is reseted to its old value right after .autoenv.sh
is executed.
Try using export AUTOENV_DEBUG=1
(e.g. in your zshrc).
And then also set -x
in the .autoenv.sh
file (at the end).
Ok, i found it. My problem had nothing to do with zsh-autoenv 😅.
I found following lines in my ~./zlogin
which is sourced on the start of each login shell and override my $PATH
after executing the .auto_env.zsh
:
export PATH="/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/texbin:/usr/local/opt/qt5/bin"
export MANPATH="/usr/local/man:$MANPATH"
I renamed it to .zshenv
to solve the problem.