Skip to content

Commit 5498f68

Browse files
committed
WIP: Fix pyenv local venv
The virtualenvs.prefer-active-python flag is currently not working for me; instead of selecting the local env, I get they poetry venv. This change resolves the problem for me. FIXES: python-poetry#8119
1 parent fedff6d commit 5498f68

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: src/poetry/utils/env/env_manager.py

+6
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,12 @@ def get(self, reload: bool = False) -> Env:
237237
prefer_active_python = self._poetry.config.get(
238238
"virtualenvs.prefer-active-python"
239239
)
240+
if prefer_active_python:
241+
executable = self._detect_active_python()
242+
bin_dir = executable.parent
243+
path = bin_dir.parent
244+
return VirtualEnv(path, Path(executable.name))
245+
240246
python_minor = self.get_python_version(
241247
precision=2, prefer_active_python=prefer_active_python, io=self._io
242248
).to_string()

0 commit comments

Comments
 (0)