Skip to content

Commit

Permalink
Add check for empty WORKON_HOME (sorin-ionescu#1861)
Browse files Browse the repository at this point in the history
When $WORKON_HOME is not set and $ENV_NAME is equal to
$PROJECT_ROOT/.venv which contains bin/activate then
the code wrongly assumes workon is available.

It should execute the second branch to source bin/activate.
  • Loading branch information
RIT80 committed Jul 27, 2020
1 parent b5bdf58 commit 0c4ec46
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion modules/python/init.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ function _python-workon-cwd {
if [[ "$ENV_NAME" != "" ]]; then
# Activate the environment only if it is not already active
if [[ "$VIRTUAL_ENV" != "$WORKON_HOME/$ENV_NAME" ]]; then
if [[ -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
if [[ -n "$WORKON_HOME" && -e "$WORKON_HOME/$ENV_NAME/bin/activate" ]]; then
workon "$ENV_NAME" && export CD_VIRTUAL_ENV="$ENV_NAME"
elif [[ -e "$ENV_NAME/bin/activate" ]]; then
source $ENV_NAME/bin/activate && export CD_VIRTUAL_ENV="$ENV_NAME"
Expand Down

0 comments on commit 0c4ec46

Please sign in to comment.