From 5c532a85cf7c4f1d5bf6b9fd35e964b4545c8de3 Mon Sep 17 00:00:00 2001 From: Carlo Sala Date: Thu, 1 Aug 2024 20:07:55 +0200 Subject: [PATCH] fix(pyenv)!: do not load if a virtualenv is present BREAKING CHANGE: `pyenv` will not be loaded at startup anymore if a virtual env if found to avoid overwriting the expected python version. Closes #12589 --- plugins/pyenv/README.md | 2 +- plugins/pyenv/pyenv.plugin.zsh | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/plugins/pyenv/README.md b/plugins/pyenv/README.md index f18fc8cfb..95d79cb52 100644 --- a/plugins/pyenv/README.md +++ b/plugins/pyenv/README.md @@ -2,7 +2,7 @@ This plugin looks for [pyenv](https://github.com/pyenv/pyenv), a Simple Python version management system, and loads it if it's found. It also loads pyenv-virtualenv, a pyenv -plugin to manage virtualenv, if it's found. +plugin to manage virtualenv, if it's found. If a venv is found pyenv won't load. To use it, add `pyenv` to the plugins array in your zshrc file: diff --git a/plugins/pyenv/pyenv.plugin.zsh b/plugins/pyenv/pyenv.plugin.zsh index 48c8ffaf5..b5c9a7bd3 100644 --- a/plugins/pyenv/pyenv.plugin.zsh +++ b/plugins/pyenv/pyenv.plugin.zsh @@ -1,3 +1,7 @@ +# if there is a virtualenv already loaded pyenv should not be loaded +# see https://github.com/ohmyzsh/ohmyzsh/issues/12589 +[[ -n ${VIRTUAL_ENV:-} ]] && return + pyenv_config_warning() { [[ "$ZSH_PYENV_QUIET" != true ]] || return 0